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

i am making rebirths and the script wont work can you help?

everytime people rebirth the out put has a error the code is:

game.ReplicatedStorage.Milktest.OnServerEvent:Connect(function(player)
	local milk = player.PlayerGui.ScreenGui.StatsValue.milk
	local Coins = player.PlayerGui.ScreenGui.StatsValue.Coins
	local Rebirths = player.PlayerGui.ScreenGui.StatsValue.Coins
	local rebirthmultiplyer = player.PlayerGui.ScreenGui.StatsValue.Rebirthmultiplier
	local ammountneededtorebirth = player.PlayerGui.ScreenGui.StatsValue.AmmountneededtoRebirth
	local ammountperrebirth = player.PlayerGui.ScreenGui.StatsValue.Ammountperrebirth
	local ammountperrebirth = theRebirth.Value * Rebirths.Value
	milk.Value = milk.Value + 1
	player.PlayerGui.ScreenGui.Frame.Rebirth.MouseButton1Click:Connect(function()
	if Coins > ammountneededtorebirth then -- this is whats wrong here
		Rebirths.Value = Rebirths.Value + 1
		rebirthmultiplyer.Value = rebirthmultiplyer.Value + 0.1
		theRebirth = ammountperrebirth
		Coins = 0
	end
end)

in this case the error would be " 08:42:44.653 - ServerScriptService.Main:37: attempt to compare userdata" but if i change the bit thats to .Value on both of the ends then i get this " 08:41:21.626 - ServerScriptService.Main:37: attempt to index number with 'Value'".

1 comment

0

please

1 answer

You syntax is incorrect. use:

game.ReplicatedStorage.Milktest.OnServerEvent:Connect(function(player)
    local milk = player.PlayerGui.ScreenGui.StatsValue.milk
    local Coins = player.PlayerGui.ScreenGui.StatsValue.Coins
    local Rebirths = player.PlayerGui.ScreenGui.StatsValue.Coins 
    local rebirthmultiplyer = player.PlayerGui.ScreenGui.StatsValue.Rebirthmultiplier
    local ammountneededtorebirth = player.PlayerGui.ScreenGui.StatsValue.AmmountneededtoRebirth
    local ammountperrebirth = player.PlayerGui.ScreenGui.StatsValue.Ammountperrebirth
    local ammountperrebirth = theRebirth.Value * Rebirths.Value
    milk.Value = milk.Value + 1
    player.PlayerGui.ScreenGui.Frame.Rebirth.MouseButton1Click:Connect(function()
    if Coins.Value > ammountneededtorebirth.Value then 
        Rebirths.Value = Rebirths.Value + 1
        rebirthmultiplyer.Value = rebirthmultiplyer.Value + 0.1
        theRebirth = ammountperrebirth
        Coins.Value = 0
    end
end)

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