I want to do like something like if u touch the brick then it will makes my walkspeed 10+ every time i walk on it i tried everything i could do and it wont work
script.Parent.Touched:connect(function(touched) touched.Parent.Humanoid.WalkSpeed = +10 end)
i want to add 10+ do my walkspeed but idk how
Do the followng.
local deb = false script.Parent.Touched:Connect(function(touched) if touched.Parent:FindFirstChild('Humanoid') and not deb then deb = true touched.Parent.Humanoid.WalkSpeed = touched.Parent.Humanoid.WalkSpeed + 10 deb = false end end)
I edited some things to make it better.
simple,
script.Parent.Touched:Connect(function(touched) local humanoid = touched.Parent:FindFirstChild("Humanoid") if humanoid then humanoid.WalkSpeed = humanoid.WalkSpeed + 10 end end)
please accept answer if you found this useful
local touch_debounce = .5 local add_walkspeed = 10 local touchers = {} local function addws(player, hum) hum.WalkSpeed = hum.WalkSpeed + add_walkspeed touchers[player.Name] = tick() end script.Parent.Touched:Connect(function(hit) -- Make sure we're actually a player and not an npc or other local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then local hum = player.Character:findFirstChild("Humanoid") -- Make sure we didn't reset on it if hum and hum.Health > 0 then -- Check if we touched the part already -- This is so we can have a seperate wait for each player local touched_already = touchers[player.Name] -- If the player is already in the table. if touched_already then -- If the player passed the wait time to get more speed if tick() - touched_already > touch_debounce then print("Already in table and passed debounce time") addws(player, hum) else print("Waiting for debounce time to end") end else -- If the player isn't in the table yet -- add them and give them + 10ws print("Add to table") addws(player, hum) end end end end)