Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Help with Owner only door?

Asked by 9 years ago

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.

1 answer

Log in to vote
3
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
9 years ago

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)
0
This just kills everyone who enters it NinjoOnline 1146 — 9y
0
Well then I guess no one's name is equal to the Owner.Value :P Goulstem 8144 — 9y
0
i fixed it, but now it just lets everyone through again NinjoOnline 1146 — 9y
0
nvm, it still kills the player. It definitely has an owner, cause I checked the workspace on server mode. NinjoOnline 1146 — 9y
0
editted my answer with output NinjoOnline 1146 — 9y
Ad

Answer this question