What do you want to achieve? Keep it simple and clear!
I’m making a regen button that when you click it, it looks for a number value inside the player that clicked it and then teleports the player inside the model and waits the amount of time in that number value inside the player and then it destroys the model the player is inside of and resets their number value.
What is the issue? Include screenshots / videos if possible!
The issue is: as soon as you click the button it teleports you into the model but it instantly destroys the model instead of waiting the time in the number value of the player and THEN destroying the model.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have noticed that if you replace the wait with a number it waits that time and then destroys the model, almost like what I want but I want it to wait the time in the number value of the player.
I have looked all over the Dev Forum but I can’t seem to find a solution. I have also looked in the output and there doesn’t seem to be any error regarding this particular script.
Code:
local modelname = "BathBoat"
------------------------------------------------------------------------------------
local modelbackup = script.Parent.Parent:FindFirstChild(modelname):clone()
local trigger = script.Parent
enabled = true
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local time1 = player:WaitForChild("BoatTime").Value
if enabled == true then
enabled = false
trigger.BrickColor = BrickColor.new("Crimson")
if script.Parent.Parent:FindFirstChild(modelname) ~= nil then
script.Parent.Parent:FindFirstChild(modelname):Destroy()
end
local modelclone = modelbackup:clone()
modelclone.Parent = script.Parent.Parent
modelclone:MakeJoints()
player.Character.HumanoidRootPart.CFrame = CFrame.new(script.Parent.Parent.BathBoat.Drive.Position + Vector3.new(0,0,0))
local time1 = player:WaitForChild("BoatTime").Value
wait(time1)
script.Parent.Parent:FindFirstChild(modelname):Destroy()
enabled = true
trigger.BrickColor = BrickColor.new("Lime green")
end
end)
I hope a solution is found. Thanks!