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

So the output isn't detecting the player touching the part sand. Anyone know why?

Sand = game.Workspace:WaitForChild("Sand")
local TouchableParts = {}
local tableposition = 1

for i, v in pairs (Sand:GetChildren()) do
    if v:IsA("BasePart") then
        table.insert(TouchableParts, tableposition, v)
        tableposition = tableposition + 1
    end
end



for i, v in pairs (Sand:GetChildren()) do
    if v:IsA("BasePart") then
        table.insert(TouchableParts, tableposition, v)
        tableposition = tableposition + 1
    end
    wait()
end


for i, v in pairs (TouchableParts) do
    v.Touched:Connect(function(hit)
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        if player then
           game.ReplicatedStorage.GravityController.disabled = false
		end
    end)
end

2 comments

0

Wouldn't the for loop only cycle through that once? Shouldn't you be constantly checking whether or not the parts have been touched?

0

How would I do that @akatak_prime?

1 answer

You don't need a for loop in this case

I made a simple script for you to follow.

Sand = game.Workspace:WaitForChild("Sand")
 script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") then
		-- do whatever you want here

	end
end)

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