so basically even when i hit the “ownersetter”(a pad i made to set player ownership of the tycoon) and it sets the players name to a stringvalue in the tycoon model, whenever i hit the “cash collector” pad it wont recognize that the player hitting it is indeed the owner please help here is the .rbxl Workspace.rbxl (32.6 KB) (i only made this for practice of my scripting skills)
local owner = tycoon.Owner.Value
pad.Touched:Connect(function(hit)
local Player = game.Players:GetPlayerFromCharacter(hit.Parent)
if hit.Parent:FindFirstChild("Humanoid") and hit.Parent.Name == owner then
print("test")
end
end)
Here is your original script. When you do local owner = tycoon.Owner.Value
, you are creating the variable equal to the owner
value when the game starts. Since the player obviously hasn’t been able to select their tycoon, owner
will be set to nil.
Instead, you should instantiate owner as local owner = tycoon.Owner
, and in the check do if hit.Parent.Name == owner.Value
, so it will check against it’s current value.
sorry for the late reply but THANK U! i have had this issue for DAYS non stop and i couldnt figure out how to fix it! from my understanding if u wanna make a variable referring to a value make sure it is reffering to the object not the .Value of it(atleast i think thats how it works)
That’s exactly it. Getting the Value of an object will return what it’s current storing, in this case an empty string. Getting the object itself allows you to get the current Value at anytime with it’s .Value