Due to complications (with FE) I need to convert my code so that it will work in a regular script in ServerScriptService but currently it only works in a LocalScript in StarterGui. Can someone please help?
Code:
local plr = game.Players.LocalPlayer local petname = game.Players.LocalPlayer.Pet.PetName.Value local mesh = game.ReplicatedStorage:FindFirstChild(petname) -- local fly = game.Players.LocalPlayer.Pet.DoesItFly.Value ------------------------------------------------------------- wait(2) local part = Instance.new('Part', workspace[plr.Name].Torso) part.CanCollide = false part.Anchored = true part.Size = Vector3.new(1,1,1) mesh:Clone().Parent = part local direction = CFrame.new(part.Position, plr.Character['Left Leg'].Position).lookVector local increment = direction * 4 while true do wait() part.CFrame = game.Workspace[plr.Name]['Torso'].CFrame + (direction * increment) + Vector3.new(-5,0,0) part.Rotation = game.Workspace[plr.Name]['Torso'].Rotation + (direction * increment) + Vector3.new(-1,-2,increment) end
Put a RemoteEvent in ReplicatedStorage named "UpdatePet", if you change the name of it change the name in the lines that start with "local RemoteEventName = "
In the local script you had before:
local RemoteEventName = "UpdatePet" wait(2) game:GetService("ReplicatedStorage"):WaitForChild(RemoteEventName):FireServer()
In a server script in ServerScriptService:
local RemoteEventName = "UpdatePet" game:GetService("ReplicatedStorage"):WaitForChild(RemoteEventName).OnServerEvent:Connect(function(plr) local petname = plr.Pet.PetName.Value local mesh = game.ReplicatedStorage:FindFirstChild(petname) -- local fly = plr.Pet.DoesItFly.Value ------------------------------------------------------------- local part = Instance.new('Part', workspace[plr.Name].Torso) part.CanCollide = false part.Anchored = true part.Size = Vector3.new(1,1,1) mesh:Clone().Parent = part local direction = CFrame.new(part.Position, plr.Character['Left Leg'].Position).lookVector local increment = direction * 4 while true do wait() part.CFrame = game.Workspace[plr.Name]['Torso'].CFrame + (direction * increment) + Vector3.new(-5,0,0) part.Rotation = game.Workspace[plr.Name]['Torso'].Rotation + (direction * increment) + Vector3.new(-1,-2,increment) end end)
I didn't test this, if it doesn't work let me know and I'll look into it