How can i do this in my script?

Screenshot 2024-05-11 091810

robloxapp-20240511-0914167.wmv (1.1 MB)


How can i make it so when the tool drops when the player dies, the tool moves back into its original position where the player found it from? I also put it in a local script, so this is only visible for the player who died and not the whole server

1 Like

Try saving the tool’s original CFrame in a variable, then move it back when the character dies. Here’s an example of how it would work:

-- Put this script inside of your tool

local CurrentTool = script.Parent
local ToolCFrame = CurrentTool.Handle.CFrame -- Put your tool's CFrame here
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
	
Character.Humanoid.Died:Connect(function()
	for i, Tool in pairs(Player.Backpack:GetChildren()) do
		if Tool:IsA("Tool") and Tool == CurrentTool then
			Tool.Parent = game.Workspace

			local Handle = Tool:WaitForChild("Handle") -- Change the handle part to the main part of the tool
			Handle.Anchored = true
			Handle.CFrame = ToolCFrame
		end
	end

	for i, Tool in pairs(Character:GetChildren()) do
		if Tool:IsA("Tool") and Tool == CurrentTool then
			Tool.Parent = game.Workspace
			
			local Handle = Tool:WaitForChild("Handle") -- Change the handle part to the main part of the tool
			Handle.Anchored = true
			Handle.CFrame = ToolCFrame
		end
	end
end)

I cant make an exact script for you because you didn’t give a whole lot of info but here is what you should do.

I assume that the tools spawn in fixed locations from what you said,. When the player picks up the tool you would make the tool invisible, and remove the possibility for the player to pick the tool up. The tool is still there, but effectively its not. Then when the player dies you set the tool to be visible again and give the player the opportunity to pick it back up. In a script for picking up the tool you could for example check if a a bool value under the tool is true or not to determine whether or not the player can pick it up. When you pick up the tool the game actually gives you a clone of the tool that is in replicated storage.

As for the tool dropping when the player dies, detect the players death, remove the tool from the players inventory and put a new clone of the tool from replicated storage into the workspace, make sure it is unanchored and set its position to a bit infront of the players arm, to make it seem like it falls out of his hand.

You can make a model of the tool, When the player picks it up, It become unpickable and Invisible.

1 Like

When i tried the script in the same script showed in the screenshots and the tool would just drop in front of the dead player instead of its original position the player found it in

Thats somwhat what i want to do, before this i tried to make a script where the tool would be in replicated storage and the workspace, then when the player dies a clone of it from the replicated storage folder gets moved into the workspace folder in the exact cframe location the player found it in but it didnt work

But i want the tool to be used in the game, is supposed to be used to open a door, i already have the script for it being able to open the door but i need a script for where it respawns in its original place once the player dies and im having trouble making that certain script

You’re not supposed to ask people to script for you on the devforum, you’re supposed to have tried on your own, then if you were unable to do it, then you’d ask for help.

Thats exactly what ive done, i tried to script this myself but they dont work so i use devforum to ask for help which is why i provided screenshots above to show others my attempt and see what i can be corrected on

Ah the screenshot wasn’t loading my bad, but is this running in a local script? Cause if it is, the tools will only be dropped on the client (on the players screen only).

Yes, it is being run in a local script, and i only want the respawning of the tool to only be on the players screen since in my games case, i want there to be one of each tool for each player whereas once they die they go back to the original place they found the tool in and be able to pick it up