Alright, so basically I have a horror game where I want items such as keycards, flashlights, etc to be picked up. I have them in workspace but when the player picks it up, obviously the issue is that the tool then disappears and nobody else can pick it up. How do I make the tool only disappear for that one person? I’m pretty new to scripting so an example would be nice. Thanks!
To achieve this, you can fire a remote event to the player who picked up the tool and in a local script handling the event, you would make it invisible or destroy it.
Example:
Server script that handles the player picking up the tool (whether a click detector, proximity prompt, or a custom logic for picking up tools):
local tool = --the path to the tool
*the event that handles the player picking up the tool*:Connect(function(plr:Player) --if it's a custom logic, make sure you have a way of getting the player who triggered it
*the remote event*:FireClient(plr, tool)
end)
The local script
*the remote event*.OnClientEvent:Connect(function(tool)
*destroy the tool here or make it invisible*
end)
RemoteEvents and a LocalScript.
Have the item be an anchored part in workspace, and have a proximity prompt in it.
When the prompt is triggered, the server adds the item into the players backpack, and then using a remote event, it tells the client to make the part invisible.
It keeps saying that connect is not a valid member of ProximityPrompt
The proximity prompt itself is an instance not a event, the events of a proximity prompt is this:
In your case, you would want to use the “Triggered” event. It would look something like this:
*the proximity prompt*.Triggered:Connect
So for some reason when I am triggering the proximity prompt nothing happens. I’m probably missing something but here’s my server script so far:
tool = workspace.Tools:WaitForChild(“Key”)
PlayerPickup = game.ReplicatedStorage.ToolEvents:WaitForChild(“PlayerPickup”)
proxprompt = workspace.Tools.Key.Handle:WaitForChild(“ProximityPrompt”)
proxprompt.Triggered:Connect(function(plr:Player)
PlayerPickup:FireClient(plr, tool)
end)
And here’s my local script inside of the key in workspace:
local PlayerPickup = game.ReplicatedStorage.ToolEvents:WaitForChild(“PlayerPickup”)
local tool = script.Parent
PlayerPickup.OnClientEvent:Connect(function(tool)
tool:Destroy()
end)
I’m guessing what’s going wrong is that I’m not actually adding the tool into the player’s backpack but I’m not sure
Does it get deleted on the client though? Also please use preformatted text when displaying code to make it easier to read.
Sorry about that here’s the server script with preformatted text:
tool = workspace.Tools:WaitForChild("Key")
PlayerPickup = game.ReplicatedStorage.ToolEvents:WaitForChild("PlayerPickup")
proxprompt = workspace.Tools.Key.Handle:WaitForChild("ProximityPrompt")
proxprompt.Triggered:Connect(function(plr:Player)
PlayerPickup:FireClient(plr, tool)
end)
And here’s the local script inside of my key with preformatted text:
local PlayerPickup = game.ReplicatedStorage.ToolEvents:WaitForChild("PlayerPickup")
local tool = script.Parent
PlayerPickup.OnClientEvent:Connect(function(tool)
tool:Destroy()
end)
local tool = workspace.Tools:WaitForChild("Key")
local PlayerPickup = game.ReplicatedStorage.ToolEvents:WaitForChild("PlayerPickup")
local proxprompt = workspace.Tools.Key.Handle:WaitForChild("ProximityPrompt")
proxprompt.Triggered:Connect(function(plr)
local ToolClone = tool:Clone()
ToolClone.Parent = plr.Backpack
PlayerPckup:FireClient(plr,tool)
end)
Would that go into my server script or my local script?
that would be in the serverscript.
script.Parent.Triggered:Connect(function(player)
local RS = game:GetService(“ReplicatedStorage”)
local tool = RS.Tool:Clone()
if Tool.Parent = player.Backpack then
return
end
Clone.Parent = player.Backpack
end)
This is just the first part of a script, I’ll add more but I’m doing something. Btw this is triggered by a prox prompt