✓ Accepted answer
Since you want to affect all players, you'll need to use a Remote Event, meaning you need BOTH a LocalScript and a ServerScript
I'm not sure what the function "ChangeText" is, but otherwise, your code should be structured like so:
Local Script
local frame = script.Parent
local remote = game.ReplicatedStorage.RemoteEvent
frame.TextButton2.Activated:Connect(function()
frame.Visible = false
for i = 3, 0, -1 do
ChangeText("Start constantly running "..i, "Msgs")
wait(1)
end
remote:FireServer()
frame.Visible = true
end)
Server Script
local remote = game.ReplicatedStorage.RemoteEvent
remote.OnServerEvent:Connect(function(player)
for _, v in pairs(game.Players:GetPlayers()) do
local character = workspace:FindFirstChild(v.Name)
if character.Humanoid.WalkSpeed > 16 and v.Settings.Playing.Value == true then
v.Settings.Ran.Value = true
character.Humanoid.Health = 0
end
wait()
end
end)
You can also simply set the player's health to zero when you change the "Ran" Value instead of needing another if-then clause
If you simply want the individual player to die if their WalkSpeed becomes > 16 then you can use a while loop:
Local Script
local player = game.Players.LocalPlayer
local character = workspace:WaitForChild(player.Name)
local remote = game.ReplicatedStorage.RemoteEvent
while true do
if player.Character.Humanoid.WalkSpeed > 16 then
remote:FireServer()
end
wait()
end
Server Script
local remote = game.ReplicatedStorage.RemoteEvent
remote.OnServerEvent:Connect(function(player)
local character = workspace:FindFirstChild(player.Name)
if character.Humanoid.WalkSpeed > 16 and player.Settings.Playing.Value == true then
player.Settings.Ran.Value = true
character.Humanoid.Health = 0
end
end)
Both examples have a RemoteEvent in ReplicatedStorage named "RemoteEvent" to make sure that the changes to the player happen on the server (where everyone can see them)
1 comment
Looks like you're trying to affect other players from a local script. Are you trying to kill them all from the local script?