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

TYCOON WORK 0001: Fine at studio, bugged at servertest? [SOLVED]

Asked by
davness 376 Moderation Voter
9 years ago

I've made the script below to change the tycoon ownership system. Instead of touching a button, you should to talk with an NPC to check if there is a space on the factory. If yes, you can choose if you want to enter or not.

It works fine on studio but when i open a server with two players it get bugged:

1. The first time any player asks for a place, the NPC does not answer, but it give the choices. 2. When i click yes, and i deliver the other player to the NPC, it says yes but does not give the choices. It will just give the right answer when i do it again 3. Then i deliver the owner to NPC and it says "Someone has the factory" instead of "You are the owner of it". It will only give the right answer at the second time.

And it loops infinitely... :(

script.Parent.Head.Dialog.DialogChoiceSelected:connect(function(player,choice)
    if choice.Name == "OS" then
        if script.Parent.Parent.OwnerShipSystem.Owner.Value ~= "" then
            if script.Parent.Parent.OwnerShipSystem.Owner.Value == tostring(player) then
                choice.ResponseDialog = "What the hell, you already are the owner of the factory! ._."
            else choice.ResponseDialog = "Sorry, someone has taken that place"
            end
            local t = choice:GetChildren()
            for i, v in pairs(t) do
                choice[v.Name]:Destroy()
            end
        else choice.ResponseDialog = "Yes, you can! There is a free space in the factory! Do you want to take it?"      
        end
    elseif choice.Name == "Y" then
        script.Parent.Parent.OwnerShipSystem.Owner.Value = tostring(player)
    end
    player = nil
    choice = nil
end)

EDIT: I took LordDragonZord to stypi and changed the script. After some changing, I solved the problem and it works fine. Thanks to Goulstem too for testing the system in-game. Here goes the script for who wants to learn something:

wait(.2)
script.Parent.Parent.OwnerShipSystem.Owner.Value = ""
local Chat = game:GetService("Chat")

script.Parent.Head.Dialog.DialogChoiceSelected:connect(function(player, choice)
    if choice.Name == "OS" then
        print(player.Name.." wants ownership")


        if script.Parent.Parent.OwnerShipSystem.Owner.Value == "" then
            print(player.Name.." can claim ownership")
            wait(.5)
            Chat:Chat(script.Parent.Head,"Man, you're lucky! We have an empty factory which needs to be filled. Are you sure you want to take it?", "Green")

        elseif script.Parent.Parent.OwnerShipSystem.Owner.Value == player.Name then
            choice:ClearAllChildren()
            local c = Instance.new("DialogChoice", choice)
            c.Name = "CRA"
            c.UserDialog = "Because I'm crazy, man"
            c.ResponseDialog = "Oh my god, help me..."
            print(player.Name.." is claiming his own ownership")
            wait(.5)
            Chat:Chat(script.Parent.Head,"Are you "..player.Name..", right? So, why are you claiming your own ownership?","Green")

        else
            print(player.Name.." is unlucky")
            choice:ClearAllChildren()
            local c = Instance.new("DialogChoice", choice)
            c.Name = "CRb"
            c.UserDialog = "Who has taken my place?"
            c.ResponseDialog = "Don't get mad, guy! The current owner of the factory is "..script.Parent.Parent.OwnerShipSystem.Owner.Value.."... do you have any problem with that?"

            wait(.5)
            Chat:Chat(script.Parent.Head,"Sorry, but we do not need owners for now. Come back later, please.", "Green")
            end

    elseif choice.Name == "Y" then
        script.Parent.Parent.OwnerShipSystem.Owner.Value = player.Name
    end
end)
0
I think you need to swith these two blocks of code: lines 4-11 and line 12. So that if the value is blank (meaning there is no owner), then it responds "Available". In other words, you just got the order mixed up. I'll post actuall code in an answer if you want me to. GoldenPhysics 474 — 9y
0
ok do it davness 376 — 9y
0
Nevermind. I jsut noticed you used "~=" instead of "==", so you're doing it right. What type of script is it? Do you have FilteringEnabled on? GoldenPhysics 474 — 9y
0
It's a normal script, FilteringEnabled is disabled davness 376 — 9y
View all comments (3 more)
0
Tips for most loops, you should always add a delay of some type. EzraNehemiah_TF2 3552 — 9y
0
it will just run two times davness 376 — 9y
0
ROBLOX studio runs stuff on Local to the player even if its a Server script. That might be the problem. I would RemoteEvent for this script as well, (If your not using it) MessorAdmin 598 — 9y

Answer this question