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

Need little help in this tycoon script?

Asked by 9 years ago

So im making my own tycoon, and i'm still stuck to the first script. Here is what I got:

function OnTouch(hit)
    local h = hit.Parent:FindFirstChild('Humanoid')
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if(player ~= nil)then
        if (script.Parent.Owner.Value == "") then
    if script.Parent.Name == ('Touch to claim tycoon')then
        script.Parent.Name = player.Name.."'s Tycoon"
        script.Parent.Owner.Value = player.Name
        wait(1)
                if (hit.Parent.Name == script.Parent.Owner.Value) then
            script.Parent.Head.CanCollide = false
            else
            hit.Parent.Humanoid.Health = 0
        end     
            end
        end
    end
end
script.Parent.Head.Touched:connect(OnTouch)

that is the 'Claim tycoon' door script And I got no Output so far. This script does not work.

1 answer

Log in to vote
0
Answered by 9 years ago
local ting = 0 --debouncer
owner = script.Parent.Parent.Parent.OwnerName --This is the thing that holds the owners name

function onTouched(hit)

    if ting == 0 then --debounce check
    ting = 1 --activate debounce
    check = hit.Parent:FindFirstChild("Humanoid") --Find the human that touched the button

    if check ~= nil then --If a human is found, then

        local user = game.Players:GetPlayerFromCharacter(hit.Parent) --Find human among the players
        if (user:FindFirstChild("rig") ~= nil) then 

        local user = game.Players:GetPlayerFromCharacter(hit.Parent) --Find human among the players
        local message = Instance.new("Message") --make a message
        message.Text = "You Aready own a Tycoon" --Put text into the message
        message.Parent = user --Display message to new owner only
        wait(3) --Wait to let the message display for a while
        message:remove() --Remove the message from the new owner

        else

        local user = game.Players:GetPlayerFromCharacter(hit.Parent) --Find human among the players
        owner.Value = hit.Parent.Name --save new owners name for later.

        local own = Instance.new("IntValue")
        own.Name = "rig"
        own.Parent = user


        local message = Instance.new("Message") --make a message
        message.Text = "You Now Own This Tycoon" --Put text into the message
        message.Parent = user --Display message to new owner only
        wait(3) --Wait to let the message display for a while
        message:remove() --Remove the message from the new owner




        script.Parent.Parent:remove()

        end
    end

    ting = 0 --remove debounce
    end

end

script.Parent.Touched:connect(onTouched) --Start listening for button-touchers.

I have something like this in my tycoons owner door.

0
Ok thanks. but I wont accept the answer, because you took a COMPLETELY different script. TheBigCoder 25 — 9y
Ad

Answer this question