Where do I put my local script

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)
5 Likes

I would say in the gui that you are trying to script with. I just put it different places and see what works

2 Likes

It seems like you are trying to change a part’s position or something with the remote event?

So I’d recommend putting it inside of the part, which I think should work

2 Likes

in the part dint work for me I tried it

2 Likes

Maybe try these scripts out that I just made?

These are test scripts by the way:

Client Script, inside of StarterCharacterScripts

Responds to the ClientEvent.

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)

Try it out and see what happens.

1 Like

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.

That isnt working it doesnt get the part varriable it print nothing when you print the obj

Thats weird, it was working for me earlier. Did you place the scripts where I said to place them in my other reply?

yes I did it says this error if I remove the checking part because it doent go further than that this was the error

attempt to index boolean with ‘Position’

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)

like what parts of the script have you changed

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

Put it in either StarterPlayerScripts, StarterCharacterScripts,StarterPack or StarterGui

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)

but my script is in the workspace because its activated when the player touches the part

Which one, the client or server?

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

Why didn’t you try putting the ServerScript inside of ServerScriptService though?

idk it was a touched event so I assumed it would work better

Ohhh so pretty much when the player touches the part, the Client Event will fire?
Thats what your trying to do?

yes and then the part plops in and out