Hello! I wanted to have tools on the Workspace only for the client, so it doesn’t disappear for you whenever anybody else grabs it.
I learnt by myself (I’m still a newbie, so I won’t know the most obvious things, sorry) that cloning a tool from ReplicatedStorage to Workspace with a LocalScript won’t work (unless I did something wrong, because I can’t pick them up if they’re cloned from there)
Assuming that tools work mostly with the server-side, I guess I’m supposed to use RemoteEvents, but how could I pull this off?
1 Like
remotes events will work, place the tool in workspace, detect when it is touched, destroy the tool then fire the remote to give the player the tool
2 Likes
oh yeah detecting when it is touched is on client btw
2 Likes
Thanks for the help! However I only got it to work halfways through since I’m stuck at the end:
The tool gets successfully destroyed, but I’m not sure how to get the path to the player’s backpack without using LocalPlayer (since I can’t do that in a Server Script)
btw the reason it seeks for the part name instead of the tool name is because I wanted to make something like cloning the Handle’s parent to the backpack so the script works universally (any tool with different names gets cloned to the backpack when touched with the use of only 1 local script), but I realized I couldn’t make that work properly if the tool gets destroyed beforehand. I will have to change that later.
local remote = game.ReplicatedStorage:WaitForChild("ToolEvent")
isTouched = false
game.Players.LocalPlayer.CharacterAdded:Connect(function(character)
character:WaitForChild("Humanoid").Touched:Connect(function(part)
if part.Name == "Handle" then
if not isTouched then
isTouched = true
part.Parent:Destroy()
remote:FireServer()
end
end
end)
end)
local remote = game.ReplicatedStorage:WaitForChild("ToolEvent")
remote.OnServerEvent:Connect(function(part)
game.ReplicatedStorage.TestTool:Clone().Parent = -- the route to the player's backpack would go here
end)
1 Like
When a remote event is fired to the server the player is automatically passed as the first argument, so you should replace
remote.OnServerEvent:Connect(function(part)
with
remote.OnServerEvent:Connect(function(player, part)
and get the backpack from the player
1 Like
Thanks a lot! It’s working perfectly now!