Hey!
I'm trying to make a buyable house but for some reason this if statement doesn't work. Help?
The Owner value is set to my name so the script should change the door's properties
Script:
owner = script.Parent.Parent.Owner script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if hit.Parent.Name == owner then script.Parent.Transparency = 0.5 script.Parent.CanCollide = false end end end)
owner = script.Parent.Parent.Owner --an object script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if hit.Parent.Name == owner then --hit.Parent.Name is a string and owner is an object you can't compare them script.Parent.Transparency = 0.5 script.Parent.CanCollide = false end end end)
The problem here is that you're comparing a string to a userdatum object
owner = script.Parent.Parent.Owner.Value -- I'm assuming the owner object is a StringValue so to get the value you just get the value property script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if hit.Parent.Name == owner then --here you compare 2 strings now so that should work script.Parent.Transparency = 0.5 script.Parent.CanCollide = false end end end)
This should be a fixed version!