While in studio when you click the Gui button, it gives you a "pet". When I test it in-game it doesn't give the player a pet. I'm new to FE scripting and RemoteEvents, can someone tell me what I'm doing wrong?
Gui button:
script.Parent.MouseButton1Click:connect(function() game.ReplicatedStorage.RemoteEvent:FireServer() end) -- This is a local script
Script in ServerScriptService:
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function() local target = game.ReplicatedStorage.Pet if game.Players.LocalPlayer.character:FindFirstChild("Pet") == nil then local pet = target:Clone() pet.Parent = game.Players.LocalPlayer.Character pet.Script.Disabled = false end end) -- This is a regular script
Script in pet:
local char = script.Parent.Parent local hum = char:FindFirstChild("Humanoid") local torso = char:FindFirstChild("Torso") local pet = script.Parent local maxFloat = 1 local floatInc = 0.025 local sw = false local fl = 0 while true do wait() if not sw then fl = fl + floatInc if fl >= maxFloat then sw = true end else fl = fl - floatInc if fl <=-maxFloat then sw = false end end if pet ~= nil and hum ~= nil and torso ~= nil then if hum.Health >= 0 then local cf = torso.CFrame * CFrame.new(3,2+fl,3) pet.BodyPosition.Position = Vector3.new(cf.x,cf.y,cf.z) pet.BodyGyro.CFrame = torso.CFrame * CFrame.new(3,0,-3) else break end end end -- Also, a regular script
local Event = game:GetService("ReplicatedStorage"):WaitForChild("Event") local target = game:GetService("ServerStorage"):WaitForChild("Pet") Event.OnServerEvent:Connect(function(player) if player.character:FindFirstChild("Pet") == nil then local pet = target:Clone() pet.Parent = player.Character pet.Script.Disabled = false end end)
When you call :FireServer(), the player is added as parameter. Try this code, or edit it since it's improved a bit. Tell me if there's any issues.