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

What is Wrong with my Claim Door Script?

Im trying to make it to where, It inserts Players name into the 'local owner' who touch the part 'Invisi' But it isnt working no Idea why...

Here is the script.

function onClicked (playerWhoClicked)
	local owner = { }
for _,v in pairs(game.Workspace.floor:GetChildren()) do
v["Claim Dorm"].Invisi.Touched:connect(function(hit)
	for _,l in pairs(game.Players:GetChildren())do
		if hit.Parent then
			local humanoid = l.Character:findFirstChild("Humanoid")
			if humanoid then
				script.Parent.Parent.Name = l.Name.."'s Dorm"
				table.insert(l.Name, #owner)
			end
			end
	end
	script.Parent.CanCollide = false
	script.Parent.Parent["Smooth Block Model"].CanCollide = false
	wait(5)
	script.Parent.CanCollide = true
	script.Parent.Parent["Smooth Block Model"].CanCollide = true
end)
end

	
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

2 comments

0

You have a "hit.Parent" condition when hit is never defined. You have a Click function while you're checking for someone who touched the door. Fix the hit.Parent. I'm not sure what a ClickDetector click function returns, but use whatever that is to check the player's name.

0

No, the 'hit.Parent' is inside a Touched event.

1 answer

The Touched event is inside the onClick function. So, the Touched event can only fire when ClickDetector is fired at the same time. Try making a different script that does what you need it to do, and insert it into all the doors. That's the only thing I can recommend right now, I can't test with Studio at this second.

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