Script 1
script.Parent.Head.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then local cashmoney = game.ServerStorage.MoneyStorage:FindFirstChild(player.Name) if cashmoney then local ownstycoon = cashmoney:FindFirstChild("OwnsTycoon") if ownstycoon then if ownstycoon.Value == false then if script.Parent.Parent.Parent.Owner.Value == nil then if hit.Parent:FindFirstChild("Humanoid") then if hit.Parent.Humanoid.Health > 0 then script.Parent.Parent.Parent.Owner.Value = player ownstycoon.Value = true script.Parent.Name = player.Name .. "'s Tycoon" script.Parent.Head.Transparency = 0.6 script.Parent.Head.CanCollide = false player.TeamColor = BrickColor.new(script.Parent.Parent.Parent.Name) end end end end end end end end)
Script 2
script.Parent.Head.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if script.Parent.Head.Transparency == 0.6 then if player.Name ~= script.Parent.Parent.Parent.Owner.Value then player.Character:FindFirstChild("Humanoid").Health = 0 end end end)
19:54:07.396 - Workspace.Tycoons.Bright blue.Gate.Touch to claim Ownership:6: attempt to index local 'player' (a nil value)
19:54:07.396 - Stack Begin
19:54:07.397 - Script 'Workspace.Tycoons.Bright blue.Gate.Touch to claim Ownership', Line 6
I have these 2 scripts inside a model. I am using Berezas tycoon kit, and the first script is his and the second is mine. I'm trying to get it so when a person who is not the owner walks into the door it will kill them, but this dosent work.
This is a tricky mistake. Your problem is that the Transparency
property is a float value, meaning that it's not exactly what you set it to.. so if you set it to .6
, it can be something like .60000112
or something like that.
So, because of this difficulty, the condition will never pass because it's looking for the Transparency to be EQUAL to .6
, not around.
So to fix? Make a grouped condition. Less than 7 and greater than 6.
local hed = script.Parent.Head hed.Touched:connect(function(hit) local player = game.Players:GetPlayerFromCharacter(hit.Parent) if hed.Transparency > 0.6 and hed.Transparency < .7 then if player.Name ~= script.Parent.Parent.Parent.Owner.Value then player.Character:FindFirstChild("Humanoid").Health = 0 end end end)