I want a part to move for only one player, but idk where to put the local script in playercharacterscripts or starterGui I have no idk, so what do you guys scripters use or whats the normal place to place a script like this:
local sendSound = game:GetService("ReplicatedStorage").RemoteEvents.ButtonSoundRemoteEvent
local player = game.Players.LocalPlayer
sendSound.OnClientEvent:Connect(function()
script.Parent.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y - 0.25, script.Parent.Position.Z)
local secondOff = 0.02 * player.Values.CooldownUpgrades.Value
local cooldown = 1 - secondOff
wait(cooldown)
script.Parent.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y + 0.25, script.Parent.Position.Z)
end)
local player = game:GetService("Players").LocalPlayer
local sendSound = game:GetService("ReplicatedStorage").Folder.ButtonSoundRemoteEvent
sendSound.OnClientEvent:Connect(function(obj)
if typeof(obj) == "Instance" and obj:IsA("Part") then
obj.Position = Vector3.new(obj.Position.X, obj.Position.Y - 0.25, obj.Position.Z)
local secondOff = 0.02 * player.Values.CooldownUpgrades.Value
local cooldown = 1 - secondOff
wait(cooldown)
obj.Position = Vector3.new(obj.Position.X, obj.Position.Y + 0.25, obj.Position.Z)
end
end)
Server Script, inside of ServerScriptService
messages the ClientEvent.
local sendSound = game:GetService("ReplicatedStorage").Folder.ButtonSoundRemoteEvent
game.Players.PlayerAdded:Connect(function(plr)
wait(5)
sendSound:FireClient(plr, -- part ) -- >> In the second part in the parenthesis, put the part that you are trying to change the position of.
end)
A local script does not work in workspace unless Parented to the Character. I’m not sure, but you can probably put it in StarterCharacter or StarterPlayer.
Can I see what you changed inside of the ServerScript?
(this script)
local sendSound = game:GetService("ReplicatedStorage").Folder.ButtonSoundRemoteEvent
game.Players.PlayerAdded:Connect(function(plr)
wait(5)
sendSound:FireClient(plr, -- part ) -- >> In the second part in the parenthesis, put the part that you are trying to change the position of.
end)
its really a long script but this is the important part
local sendSound = game:GetService("ReplicatedStorage").RemoteEvents.ButtonSoundRemoteEvent
local stepPart = script.Parent
sendSound:FireClient(player, inSound, outSound, stepPart)
I dont really know how to sent stuff somethimes when I remove something and then in the other one where I use the same remote event it jsut doesnt work
This script wouldn’t work at all, since there aren’t any variables for all 4 instances.
Here is the fix for the server script, make sure the server script is inside of ServerScriptService
local sendSound = game:GetService("ReplicatedStorage").Folder.ButtonSoundRemoteEvent
local stepPart = workspace:WaitForChild("stepPart")
local inSound = stepPart:WaitForChild("inSound")
local outSound = stepPart:WaitForChild("inSound")
game.Players.PlayerAdded:Connect(function(player)
wait(5)
sendSound:FireClient(player, inSound, outSound, stepPart)
end)
Also, may I see your Client Script?
(this one)
local player = game:GetService("Players").LocalPlayer
local sendSound = game:GetService("ReplicatedStorage").Folder.ButtonSoundRemoteEvent
sendSound.OnClientEvent:Connect(function(obj)
if typeof(obj) == "Instance" and obj:IsA("Part") then
obj.Position = Vector3.new(obj.Position.X, obj.Position.Y - 0.25, obj.Position.Z)
local secondOff = 0.02 * player.Values.CooldownUpgrades.Value
local cooldown = 1 - secondOff
wait(cooldown)
obj.Position = Vector3.new(obj.Position.X, obj.Position.Y + 0.25, obj.Position.Z)
end
end)
serverscript is in the part in the workspace and it still doesnt go past the to if statement because after I sent it trough the remote event it will = nil for some reason