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

walkspeed script for certain players not working?

local plrs = {"DarkFlameCrimsonXana", "PrimeCrimson", "RebornProductions", "Delshark44"}
local bs = script.Parent
function onTouch(Brick)
	local Player = 
	Brick.Parent:findFirstChild("humanoid")
	if (Player.Name == (plrs))then
		Player.Walkspeed = 100
	end
end
bs.Touched:connect(onTouch)

I don't get why it's not working, the output shows no errors and yet it's not working...

1 comment

0

What you'll also need to do is add "Player" to plrs, if you want to try your script in studio.

2 answers

✓ Accepted answer

Your if statement on line 6 is checking if their name is a Lua Table, which it obviously isn't.

To fix this, let's make this a Dictionary and change line 6:

local plrs = {DarkFlameCrimsonXana = true, PrimeCrimson = true, RebornProductions = true, Delshark44 = true}
local bs = script.Parent
function onTouch(Brick)
    local Player = game.Players:GetPlayerFromCharacteR(Brick.Parent) --This is a better method of getting the Player's name if it exists.
    if (plrs[Player.Name])then
        Player.WalkSpeed = 100
    end
end
bs.Touched:connect(onTouch)

2 comments

0

Also, make sure that 's' in Walkspeed is Capitalized. The property is 'WalkSpeed', not 'Walkspeed'.

0

cheers, i broke my arm so i could only just check it out

local plrs = {"DarkFlameCrimsonXana", "PrimeCrimson", "RebornProductions", "Delshark44"}
local bs = script.Parent
function onTouch(Brick)
    local Player = 
    Brick.Parent:findFirstChild("Humanoid") --Capitalized H
    for i,v in pairs(plrs) do
	if Player.Parent.Name==v then
		Player.Walkspeed = 100 -- You might have to write WalkSpeed idk i forgot but try it like this
	end
    end
bs.Touched:connect(onTouch)

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