Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Value in tool still not changing?

Asked by 4 years ago

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

Log in to vote
0
Answered by
zadobyte 692 Moderation Voter
4 years ago
Edited 4 years ago

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!

0
Wow thank you so much! VIPPro3456 12 — 4y
Ad

Answer this question