Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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!

18 comments

1

taken from a free model

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.

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.

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.

0

Any Errors?

0

It won't work for some reason I have it right but I don't know if there are any erros

0

Click f9 on your keyboard and see if there are any errors

0

Didn't work

0

Play the game and then click f9

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..

0

ok one sec

0

Nope no erros I think

0

hmm

0

Is the script a local script

0

no

0

change the game.Players.ChildAdded:connect(onPlayerEntered) to game.Players.PlayerAdded:Connect(onPlayerEntered)

0

witch number?

0

dude this isn't a site where you get people to code for you like this is actually stupid now

1 answer

✓ Accepted answer

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)

18 comments

0

Also it should be game.Players.PlayerAdded:Connect(onPlayerEntered)

0

Will the vote gui pop up?

0

It should

0

also do I put this in script local script or the other script

0

The Script you showed us...

0

the :connect is deprecated use :Connect() and use local VARIABLE = ... and :remove() is deprecated. change to :Destroy() and use workspace not game.Workspace

0

Oh right one more question what do I put the timer on?

0

To make sure the vote gui works?

0

It doesn't matter im sure the script should work

0

Fixed everything

0

What do I do to see if it works or not?

0

Use prints like print("Works!") and stuff like that

0

You want me to put that in the script

0

you forgot to put " local " in variables.

0

Lul

0

What number is variables in

0

The script should be working

0

It's not working.

This discussion is preserved as it was. New answers, comments, and votes are closed.