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

How to make local scripts change BoolValue?

I'm wondering how can I make a local script change the BoolValue and have the server read it. Currently I have this Crouching script that works playing the animation to everyone else, however the value stay the same (false). How do I fix this?

Player = game.Players.LocalPlayer
repeat
	wait()
until Player.Character
Mouser = Player:GetMouse()
name = Player.Name
char = game.Workspace[Player.Name]
Animation = script.Anim

animtrack = char.Humanoid:LoadAnimation(Animation)


Mouser.KeyDown:connect(function(key)
	if string.byte(key) == 48 then
		animtrack:Play()
		Player:FindFirstChild("Crouch").Value = true
		char.Humanoid.WalkSpeed = 8
			end
		end)
	
	Mouser.KeyUp:connect(function(key)
		
	 if string.byte(key) == 48  then
		script.Disabled = true
		animtrack:Stop()
		Player:FindFirstChild("Crouch").Value = false
		char.Humanoid.WalkSpeed = 16
		script.Disabled = false	
	end
end)

1 comment

0

also, use UserInputService.InputBegan instead of Mouse.KeyDown

1 answer

You can't change the server directly using a local script. You can only change it by using remote events and remote functions due to filtering enabled.

Hoped this helped!

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