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

This is very odd. . .?

Let me tell you a little bit, I see no errors in this, Yet it wont do what i am telling it to do. There is no errors in the outpost, Neither did i state/call something that is "="to nil. So, I don't know you take a look:

function CC(hit)
		if game.Players:FindFirstChild(hit.Name) then
			local p = game.Players:FindFirstChild(hit.Name)
			if p:FindFirstChild("TS") then
				if p.TS.Value == false then
					p.TS.Value = true
					script.Parent.CanCollide = false
					local O = script.Parent.Parent.Parent.Owner
					O.Value = p
					script.Parent.Parent.Name = "Taken: "..p.."."
					script.Parent.Parent.Parent.RG.Disabled = false
			end
		end
	end
end
script.Parent.Touched:connect(CC)

1 comment

0

Guys, I forgot to say "Hit.Parent.Name", FOrget it XD

1 answer

✓ Accepted answer
function CC(hit)
	if hit.Parent:FindFirstChild("Humanoid") then --Fixed checking if it's a player that touched it
		local p = game.Players:GetPlayerFromCharacter(hit.Parent) --:GetPlayerFromCharacter() is much better than your method.
		if p:FindFirstChild("TS") then
			if p.TS.Value == false then
				p.TS.Value = true
				script.Parent.CanCollide = false
				local O = script.Parent.Parent.Parent.Owner
				O.Value = p
				script.Parent.Parent.Name = "Taken: ".. p.Name .."." --Added p.Name and spaces
				script.Parent.Parent.Parent.RG.Disabled = false
            end
        end
    end
end
script.Parent.Touched:connect(CC)

2 comments

0

Spaces aren't needed for that.

0

Yeah i fixed it. still using "Find First Child" Method though.

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