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

3 comments
I'm having similar problems, just not in FE.
In server script, you can't do game.Players.LocalPlayer. This is done in the client side, local script. Also, add variables when identifying the RemoteEvent, and the pet. Example: game:GetService("ReplicatedStorage"):WaitForChild("ExampleEvent") and game:GetService("ServerStorage"):WaitForChild("Pet"). Add the pet in ServerStorage, that way the client doesn't download the pet and waste memory.
How do I fix the server script?