Still have questions? Join our Discord server and get real time help.
0

# why isnt my rebirth script not working when i touch the part?

hot_spi 20
14 days ago

so my goal here is that when you touch the part you get teleported, get 50 cash depending on how many rebirths you have. But when i have 1 rebirth, and i touch the part, it gives me 50 cash instead of 100 cash. Here's the script:

script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if Rebirths.Value > 0 then
Cash.Value = Cash.Value + (50*(Rebirths.Value + 1))
Gems.Value = Gems.Value + Rebirths.Value
else
Cash.Value = Cash.Value + 50
end
player.Character:SetPrimaryPartCFrame(CFrame.new(script.Parent.Parent.TeleportPart.Position))
end)


Can someone help me fix this problem? Or maybe even explain why i got the script wrong?

0
idk maybe try changing *else* with *elseif* PapalMache 0 — 14d
0
Before your if-statement, please try print(Rebirths.Value). It is possible that you are not incrementing the Rebirths correctly elsewhere and that it is 0 by the time you run this script. Sparks 534 — 14d

0
Edited 14 days ago

Try to do it like this:

script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local AmountToMultiply = 50
if Rebirths.Value == 1 then
Cash.Value = Cash.Value + AmountToMultiply * 2
Gems.Value = Gems.Value + Rebirths.Value
elseif Rebirths.Value > 1 then
Cash.Value = Cash.Value + AmountToMultiply * Rebirths.Value
Gems.Value = Gems.Value + Rebirths.Value
elseif Rebirths.Value <= 0 then
Cash.Value = Cash.Value + AmountToMultiply
end
player.Character:SetPrimaryPartCFrame(CFrame.new(script.Parent.Parent.TeleportPart.Position))
end)

0
but like when the rebirth value is 1 it will be 50 * 1, which didnt do anything. hot_spi 20 — 14d
0
and also the gems hot_spi 20 — 14d
0
I edited it WoGiTeam 45 — 14d