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

help with checking the string of a value in the players model?

part = script.Parent

part.Touched:Connect(function(hit)
	if hit.Name == "NodeOrb" and script.Parent.Parent.Parent.Parent.Character.TeamCol.Value == "Tred" then
		hit.CaptureStatus.Value = hit.CaptureStatus.Value + 1
	end
	if hit.Name == "NodeOrb" and script.Parent.Parent.Parent.Parent.Character.TeamCol.Value == "Tblue" then
		hit.CaptureStatus.Value = hit.CaptureStatus.Value - 1
	end
end)

the script is in a part which is inside a tool, and Im trying to access a stringvalue inside the tool owners character but Im having trouble getting to it, I thought what I had would work but I keep getting an error were the script is trying to get to the stringvalue.

is there something Im doing wrong?

1 answer

✓ Accepted answer

###For first, on equip the tool. the tool go to Player character. and you dont need to use .Character

Here is a example:

local tool = script.Parent

tool.Equiped:Connect(function()
	print("Player name: " .. script.Parent.Parent.Name)
	--[[ 
	 script = Script
	  script.Parent = tool
	   script.Parent.Parent = character.
	]]
end)

Here is fixed script:

local tool = script.Parent.Parent -- Added variable for tool
local part = script.Parent -- Use local Variable = ... not Variable = ...

part.Touched:Connect(function(hit)
	if tool.Parent:FindFirstChild("Humanoid") then -- Check if is in char.
	    if hit.Name == "NodeOrb" and tool.Parent.TeamCol.Value == "Tred" then
	        hit.CaptureStatus.Value = hit.CaptureStatus.Value + 1
	    end
	    if hit.Name == "NodeOrb" and tool.Parent.TeamCol.Value == "Tblue" then
	        hit.CaptureStatus.Value = hit.CaptureStatus.Value - 1
	    end
	end
end)

Hope it helped :D


Solved your problems? put in title [SOLVED] or accept a answer.

Errors? tell-me on comments.

1 comment

0

yes! thank you this problem has been annoying to deal with.

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