So, I have made a FilteringEnabled walkspeed boost pad. When touched, instead of the person who touched it gets the boost, everyone in the server gets it and it runs once per person in the server. Is there any way to make it run once and for the person who touched the part?
01 | --Server script |
02 | local Button = script.Parent.Button |
03 | local Event = game.ReplicatedStorage [ "Remote Events" ] [ "Bonus_Walkspeed_Pad" ] |
04 | local Duration = 3 |
05 | local Boost = 2 |
06 |
07 |
08 | Event.OnServerEvent:connect( function (Player) |
09 | local Character = Player.Character |
10 | local Humanoid = Character:FindFirstChild( "Humanoid" ) |
11 | Button.CFrame = Button.CFrame * CFrame.new( 0 , - 0.1 , 0 ) |
12 | Button.BrickColor = BrickColor.new( "Dark stone grey" ) |
13 | Humanoid.WalkSpeed = Humanoid.WalkSpeed * Boost |
14 | wait(Duration) |
15 | Button.CFrame = Button.CFrame * CFrame.new( 0 , 0.1 , 0 ) |
16 | Button.BrickColor = BrickColor.new( "Bright green" ) |
17 | Humanoid.WalkSpeed = Humanoid.WalkSpeed / Boost |
18 | end ) |
01 | --Local script |
02 | local RemoteEventFolder = game.ReplicatedStorage:WaitForChild( "Remote Events" ) |
03 | local RemoteEvent = RemoteEventFolder [ "Bonus_Walkspeed_Pad" ] |
04 | local Model = game.Workspace [ "Button FilteringEnabled" ] |
05 | local Enabled = true |
06 |
07 | Model:FindFirstChild( "Button" ).Touched:connect( function (Hit) |
08 | if Hit.Parent and Hit.Parent:FindFirstChild( "Humanoid" ) and game.Players:FindFirstChild(Hit.Parent.Name) and Hit.Parent:FindFirstChild( "Humanoid" ).Health > 0 then |
09 | if Enabled = = true then |
10 | Enabled = false |
11 | RemoteEvent:FireServer() |
12 | wait( 4 ) |
13 | Enabled = true |
14 | else |
15 | print ( "Already Fired, waiting for cooldown." ) |
16 | end |
17 | end |
18 | end ) |
Your local scripts are checking to see if any player is touching the brick, instead of just the LocalPlayer. Then, regardless of which player they found, they tell the server "Activate for my player please" (as the LocalPlayer is always sent as the first argument to RemoteEvents/Functions). The server has no debounce, and so doesn't mind giving more than one person a boost.
You should merge the scripts into a single Script (on the server), removing all references to the RemoteEvent (where you normally call the RemoteEvent, just call the function responsible for boosting a player). There needn't be any client/LocalScript interaction here, since Touched
events fire on the server as well.
Yes there is, Try using Firing a client only for the player,which raises the walkspeed.