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

Help I need to fix this script it's not working it suppose to regen the model? (Read Desc)

Asked by 6 years ago

I was trying to do is make it where the player can vote to regen the model. The voting thing should pop up and should have a timer. Here's the script I was working on.

map = game.Workspace.ship--Noob
print("It works if this was printed")


voted = {}
votes = 0
time = 0

function onChatted(msg, recipient, speaker)
    if string.lower(string.sub(msg,1,10)) == "voteregen" then
        if playervoted(speaker.Name) == false then
            table.insert(voted, speaker.Name)
            print( speaker.Name ..  " Inserted.")
            votes = votes + 1
            if time == 0 then
                dotimer()
            end
        end
    end
end


function dotimer()

    for i = 1, 60 do
        time = time + 1
        wait(1)
    end
    time = 0
end
function playervoted(player)
    try = voted[player]
    if try ~= nil then
        return true
    end
    return false
end

function onPlayerEntered(newPlayer)
    newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
end

function respawn(model)
    backup = model:clone()
    model:remove()
    wait(2)
    model = backup:clone()
    model:makeJoints()
    model.Parent = game.Workspace
end


function startvote()
    if votes ~= 0 then
        if votes >= 5 and time < 60 then
            respawn(map)
        end
    end
end

game.Players.ChildAdded:connect(onPlayerEntered)

Thanks!

1
taken from a free model User#24403 69 — 6y
1
Dude We have been doing all your scripts for you. You need to learn how to code instead of all of us doing it for you. MrGaming4me 28 — 6y
1
Also there you aren't explaining the script at all all you did was paste the script you didn't even tell us the error. MrGaming4me 28 — 6y
0
Look I promise you if you help me with this I won't ask for anything for tomorrow and for today. I just want this last thing and i'll be gone you won't see me until 3 days. dontban_mer -36 — 6y
View all comments (14 more)
0
Any Errors? MrGaming4me 28 — 6y
0
It won't work for some reason I have it right but I don't know if there are any erros dontban_mer -36 — 6y
0
Click f9 on your keyboard and see if there are any errors MrGaming4me 28 — 6y
0
Didn't work dontban_mer -36 — 6y
0
Play the game and then click f9 MrGaming4me 28 — 6y
0
The model probably doesn't exist so that means you are cloning something that doesn't exist, define it at the start of the code and clone it from there.. greatneil80 2647 — 6y
0
ok one sec dontban_mer -36 — 6y
0
Nope no erros I think dontban_mer -36 — 6y
0
hmm MrGaming4me 28 — 6y
0
Is the script a local script MrGaming4me 28 — 6y
0
no dontban_mer -36 — 6y
0
change the game.Players.ChildAdded:connect(onPlayerEntered) to game.Players.PlayerAdded:Connect(onPlayerEntered) yHasteeD 1819 — 6y
0
witch number? dontban_mer -36 — 6y
0
dude this isn't a site where you get people to code for you like this is actually stupid now Metraria 17 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Ok I found the problem you should be check for a nil not false here is the code

local map = workspace.ship--Noob
print("It works if this was printed")


voted = {}
votes = 0
time = 0

function onChatted(msg, recipient, speaker)
    if string.lower(string.sub(msg,1,10)) == "voteregen" then
        if playervoted(speaker.Name) == nil then
            table.insert(voted, speaker.Name)
            print( speaker.Name ..  " Inserted.")
            votes = votes + 1
            if time == 0 then
                dotimer()
            end
        end
    end
end


function dotimer()

    for i = 1, 60 do
        time = time + 1
        wait(1)
    end
    time = 0
end
function playervoted(player)
    try = voted[player]
    if try ~= nil then
        return true
    end
    return false
end

function onPlayerEntered(newPlayer)
    newPlayer.Chatted:Connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
end

function respawn(model)
    backup = model:clone()
    model:Destroy()
    wait(2)
    model = backup:clone()
    model:makeJoints()
    model.Parent = game.Workspace
end


function startvote()
    if votes ~= 0 then
        if votes >= 5 and time < 60 then
            respawn(map)
        end
    end
end

game.Players.PlayerAdded:Connect(onPlayerEntered)
0
Also it should be game.Players.PlayerAdded:Connect(onPlayerEntered) MrGaming4me 28 — 6y
0
Will the vote gui pop up? dontban_mer -36 — 6y
0
It should MrGaming4me 28 — 6y
0
also do I put this in script local script or the other script dontban_mer -36 — 6y
View all comments (14 more)
0
The Script you showed us... MrGaming4me 28 — 6y
0
the :connect is deprecated use :Connect() and use local VARIABLE = ... and :remove() is deprecated. change to :Destroy() and use workspace not game.Workspace yHasteeD 1819 — 6y
0
Oh right one more question what do I put the timer on? dontban_mer -36 — 6y
0
To make sure the vote gui works? dontban_mer -36 — 6y
0
It doesn't matter im sure the script should work MrGaming4me 28 — 6y
0
Fixed everything MrGaming4me 28 — 6y
0
What do I do to see if it works or not? dontban_mer -36 — 6y
0
Use prints like print("Works!") and stuff like that MrGaming4me 28 — 6y
0
You want me to put that in the script dontban_mer -36 — 6y
0
you forgot to put " local " in variables. yHasteeD 1819 — 6y
0
Lul MrGaming4me 28 — 6y
0
What number is variables in dontban_mer -36 — 6y
0
The script should be working MrGaming4me 28 — 6y
0
It's not working. dontban_mer -36 — 6y
Ad

Answer this question