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

Pellet won't stop going down when it touches something?

Hello there, I just made this script where when the pellet is touched by a player, it increases their walkspeed, but when it touches a part that is not a player, it will stop going down so a player can catch it. Here is the code.

local touch = false
local humtouch = false

while humtouch == false do
    if touch == false then
	    script.Parent.Position = script.Parent.Position + 				Vector3.new(0, -0.5, 0)
    end

script.Parent.Touched:Connect(function(hit)
touch = true
local hum = hit.Parent:FindFirstChild("Humanoid")
    if hum then
	    if humtouch == false then
		    humtouch = true
		    hum.WalkSpeed = hum.WalkSpeed + 5
		    addbeam(tostring(hit.Parent.Name))
		    script.Parent.CanCollide = false
			   for i = 0, 1, 0.1 do
				    script.Parent.Transparency = i
				    wait(0.05)
			    end
script.Parent:Destroy()
    end
	    end
end)
wait()
end

Howcome it detects only the player touching it, but not if any other part is touched? Help is appreciated.

1 comment

0

the code looks weird because idk how to use the new system and idk how to fix it

1 answer

Because your Touched function only activates

touched = false

and then if touched by a player it will stopped. So to fix this, move the line that stops the pellet below the line of touched = false

2 comments

0

could you be more specific to what the fix is? i've tried anything

0

The problem is when the touch functions, if it is touched by a player it will get destroyed but if it is not touched by a player, it won't get destroy nor stop.

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