So I am currently struggling with a piece of my script, It works fine as it is, but when it adds the ‘deployable’, it will only show for the person that placed it (blah blah clientside)
Basically, I want the deployable to be serverside and show for everyone instead of the just the person who placed it.
It uses a local script inside a tool at the moment
local deployable = script.Parent
local deployed = false
local runService = game:GetService("RunService")
--------------------------------------------------------------------------------
local OGpiece = game.ReplicatedStorage.LightStand
--------------------------------------------------------------------------------
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
local Equip = humanoid:LoadAnimation(script.Parent.LargeDeployableEquip)
local Idle = humanoid:LoadAnimation(script.Parent.LargeDeployableIdle)
--------------------------------------------------------------------------------
deployable.Equipped:Connect(function()
Equip:Play()
wait(3.32)
Equip:Stop()
Idle:Play()
deployable.Activated:Connect(function()
runService.Heartbeat:Connect(function()
local currentPivot = character:GetPivot()
end)
local currentPivot = character:GetPivot()
local copy = OGpiece:Clone()
copy:PivotTo(currentPivot * CFrame.new(0,0,-2))
copy.Parent = workspace
wait(.5)
Idle:Stop()
Equip:Stop()
script.Parent:Destroy()
end)
end)
deployable.Unequipped:Connect(function()
Idle:Stop()
Equip:Stop()
end)
There’s absolutely no way you can make a LocalScript serversided. The server just won’t replicate things unless it’s network ownership is set to said player, like a part.
A good way to accomplish this is with remoteevents. Have it done on the server, I would write the script for you, but I don’t really understand your code that well. Basically, Fire a remoteevent on the client, with all the data you need, and on the server, using a serverscript you can listen for when the remoteevent is fired using .OnServerEvent. Beware though, the first parameter is always the player that fired the event. Example:
-- client
event:FireServer(number)
-- server
event.OnServerEvent:Connect(function(player, number) end)
Do anything you know won’t replicate to everyone else on the server.
If it’s a tool it’s possible to use the events you wrote in your client script like so with a server script. But I’m not sure if that’s your best option. (Basically create a server script and add the activated event while also keeping the local script).
Edit:
Since you’re using RunService I suggest doing what @Den_vers just said. It’s not really recommended to use this function in a server script unless really needed (can cause accuracy issues).