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
COMMUNITY QUESTION
So the output isn't detecting the player touching the part sand. Anyone know why?
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.

2 comments
Wouldn't the for loop only cycle through that once? Shouldn't you be constantly checking whether or not the parts have been touched?
How would I do that @akatak_prime?