So I have a script called "GravityController" that is being destroyed in the script when a player touches the part "Sand". Once the "GravityController" script is destroyed then it will reload the character essentially. So does anyone know how to "Reload" a character using a script?
local Sand = game.Workspace:WaitForChild("Sand")
local Debounce = false
Sand.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
if Debounce == false then Debounce = true
game.ReplicatedStorage.GravityController:Destroy()
print("Module successfully destroyed")
end
end
end)
local player = workspace:FindFirstChild("Player")
ResetPoint = CFrame.Position
player.Position = Vector3.new(ResetPoint)
if game.ReplicatedStorage.GravityController:Destroy() then
local part = workspace.FindFirstChild("Sand")
part.Anchored = true
part.Parent = workspace
part.Touched:connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum then
hum.Health = 0
end
end)
end
local part = workspace.FindFirstChild("Sand")
part.Touched:connect(function(hit)
local hum = hit.Parent:FindFirstChild("Humanoid")
if hum.Health = 0 and game.ReplicatedStorage.GravityController:Destroy() then
player.Position = Vector3.new(ResetPoint)
end
end)

2 comments
Instance:Destroy() returns nothing so the if statement never runs.
https://scriptinghelpers.org/questions/63507/how-do-i-make-a-player-respawn-instantly