Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Value in tool still not changing?

Hello,Im trying to do a recoil script and I did a local and a serverscript.But when I change the value in the tool in the local script,the script in the tool still says that it's false.

Local Script:

mos.Button1Up:Connect(function()
	basilli = false
	script.Parent.Server.Basilli.Value = false
end)



script.Parent.Activated:Connect(function()
		basilli = true
		script.Parent.Server.Basilli.Value = true
		repeat wait()
		local FireDirection = (Mouse.Hit.Position - FirePointObject.WorldPosition).Unit
			MouseEvent:FireServer(FireDirection)
		until basilli == false
	end)	
		

Server Script:(just that line)

while wait() do
	print(script.Basilli.Value)
	if script.Basilli.Value == true then
		MAX_BULLET_SPREAD_ANGLE = 10
	end
end

1 answer

✓ Accepted answer

Changes on the client don't replicate to the server. You can use the remote event you fired to send the value to the server and change it.

--Client
MouseEvent:FireServer(FireDirection, script.Basilli)

then:

--Server
MouseEvent.OnServerEvent:Connect(function(player, FireDirection, Basilli) -- the player is always the first parameter of OnServerEvent
	Basilli.Value = true --the server will see this and will therefore change for the server and not just the client.
end)

Please accept the answer if I solved your problem!

1 comment

0

Wow thank you so much!

This discussion is preserved as it was. New answers, comments, and votes are closed.