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

So I keep getting this error Expected '(','{' or <string>, got ':' On line 25. Help?

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


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
    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 answers

✓ Accepted answer

Change line 25 to this:

v.Touched:Connect(function(hit)

Maybe it was my error from yesterday when I answered your question. it's v.Touched and not v:Touched (the dot)

1 comment

0

Thanks. oh and btw I found out I shouldn't destroy the script instead I should just disable it

I assume that Touched, in this case, is a property of TouchableParts[v], so try replacing the colon with a period.

-- Replace
v:Touched:Connect(function(hit)

-- with
v.Touched:Connect(function(hit)

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