Hi I am trying to get a string that has been stored and when a part is touched it checks if the string matches. when i touch the part nothing happens, what am i doing wrong?
function OnTouched(Part)
local str = ""
local player = game.Players:GetPlayerFromCharacter(Part.Parent)
if player then
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
str = leaderstats.Rank.Value
if string.match(str, "Rec") then
print("Works")
else
print("doesnt work")
end
end
end
end

1 comment
Also did you add a Part.Touched:Connect(OnTouched) at the end?