Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Insert a number to close a function?

Asked by 4 years ago

Hi guys, i have this code

local sound = Instance.new("Sound", game.Workspace)
sound.SoundId = "rbxassetid://3625290171"

local player = game:GetService("Players").LocalPlayer
local ShowMessage = player.Backpack:WaitForChild("ShowMessage")
MESSAGE_DELAY = 3.5

function dmt(hit)
if hit.Parent ~= nil then
local player = game.Players:playerFromCharacter(hit.Parent)
    if player ~= nil then
        if player.leaderstats.PhereStage.Value == script.Parent.Name - 1 then
        local h = hit.Parent:FindFirstChild("Humanoid")
            if h ~= nil then
                if h.Health ~= 0 then
                ShowMessage:Fire("Complimenti! Hai superato la fase " .. player.leaderstats.PhereStage.Value .. "!", true)
                sound:Play()
                end 
            end 
        end 
    end
 end
end

workspace.StartPhere.1.Touched:connect(dmt)

I think the problem is at the end

workspace.StartPhere.1.Touched:connect(dmt)

I have 0 errors in console, but 1 error inside the script:

Expected '=' when parsing assignment, got '.1.Touched'

i NEED call this Model "1", i can't change it. How i can fix?

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago

Change line 25 to:

workspace.StartPhere['1'].Touched:connect(dmt)

That should fix it.

Ad

Answer this question