Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Flora Generation Client-Side
- wait(2)
- ReplicatedStorage = game:GetService("ReplicatedStorage")
- floraEvent = ReplicatedStorage:WaitForChild("floraEvent") blightEvent = ReplicatedStorage:WaitForChild("blightEvent")
- leafEvent = ReplicatedStorage:WaitForChild("leafEvent")
- flora = ReplicatedStorage:WaitForChild("Flora")
- function generateFlora(group,targ,node) -- Moves models into the workspace on the client, based on distance from the plants center
- local plant = flora:FindFirstChild(targ)
- local p2 = plant:Clone()
- p2.Parent = group
- print("Planted!")
- wait(.01)
- p2.smallNode.CFrame = CFrame.new(node)p2.smallNode.Anchored = true
- fadeIn(p2)
- end
- function fadeOut(targ) -- visual fade effects
- for i, v in pairs (targ:GetChildren()) do wait(.001)
- for i = 1,10 do
- v.Transparency = v.Transparency + .1
- end
- end
- end
- function fadeIn(targ)
- for i, v in pairs (targ:GetChildren()) do wait(.001)
- for i = 1,10 do
- v.Transparency = v.Transparency - .1
- end
- end
- end
- floraEvent.OnClientEvent:Connect(function(...) --Server fires remote event when player is within range,generates flora based on strings
- local args = {...}
- for _, arg in pairs(args) do
- end
- wait(.01) --print (args[23]) print (args[24])
- local v = args[3] generateFlora(args[1],v, args[4])
- local v = args[5] generateFlora(args[1],v, args[6])
- local v = args[7] generateFlora(args[1],v, args[8])
- local v = args[9] generateFlora(args[1],v, args[10])
- local v = args[11] generateFlora(args[1],v, args[12])
- local v = args[13] generateFlora(args[1],v, args[14])
- local v = args[15] generateFlora(args[1],v, args[16])
- end)
- leafEvent.OnClientEvent:Connect(function(...) --Flora generation for leaves specifically
- local args = {...}
- for _, arg in pairs(args) do
- end
- wait(.01) print (args[1])print (args[2]) print (args[3])print (args[4]) print (args[5])print (args[7])
- local v = args[3] generateFlora(args[1],v, args[2])
- local v = args[5] generateFlora(args[1],v, args[4])
- local v = args[7] generateFlora(args[1],v, args[6])
- end)
- blightEvent.OnClientEvent:Connect(function(...) --removes plants when player exits range
- local args = {...}
- for _, arg in pairs(args) do
- --print("Located")
- end
- local x = args[1]
- local g = x:GetChildren()
- for i, v in pairs(g) do wait(.001) if v.ClassName == "Model" then fadeOut(v) wait(.001) v:Destroy()
- end end end)
- ---------------Server-Side--------
- plrs = game:GetService("Players") leafEvent = game.ReplicatedStorage:WaitForChild("leafEvent") blightEvent = game.ReplicatedStorage:WaitForChild("blightEvent")
- d = 0 local a1 = script.Parent.Parent n1 = a1.smallNode1 n2 = a1.smallNode1.floraType.Value Debounce = true
- --Nodes = small transparent parts used for prop positioning
- gen = true
- while true do wait(.1)
- for i , v in ipairs (plrs:GetChildren()) do
- local char = v.Character
- d = (char.UpperTorso.Position - script.Parent.Position).magnitude -- distance between current player and current props
- if d < 200 and gen == true and Debounce == true then gen = false Debounce = false
- leafEvent:FireClient(v,a1, -- call client to generate props locally
- a1.smallNode1.Position,a1.smallNode1.floraType.Value,
- a1.smallNode2.Position,a1.smallNode2.floraType.Value, --1,2
- a1.smallNode3.Position,a1.smallNode3.floraType.Value)
- wait(.2)
- Debounce = true
- --print("Generating Flora")
- elseif d > 200 and gen == false and Debounce == true then gen = true Debounce = false
- blightEvent:FireClient(v,a1)
- wait(.2) Debounce = true
- -- print ("Deleting Flora")
- end end end
Advertisement
Add Comment
Please, Sign In to add comment