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

Insert a number to close a function?

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

✓ Accepted answer

Change line 25 to:

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

That should fix it.

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