I’ve been having some issues with making local scripts actually run in my game. I have a tool in the workspace that requires a proximity prompt to equip. However, the script will not run when inside of the tool, so I put it in the StarterPlayerScripts. When it moves to the player’s backpack, there are more issues with variables since all of the parts have been moved. Where should I put the Local Script/how can I do this?
Local scripts can only run in places where only the client has control eg. PlayerScripts, PlayerGui. So local scripts will only work if placed in a ‘Starter’ folder. Now as for this problem, you can listen for the prompt triggered on the client as it doesn’t really make a difference (code in local script in StarterPLayerScripts)
local tool = workspace.Sword -- Change this to your tool
local player = game.Players.LocalPlayer
tool.Handle.ProximityPrompt.Triggered:Connect(function(plr)
if not plr.Name == player.Name then return end --[[Check to see if
only the local player activated it]]
tool.Parent = plr.Backpack
end)
This should work
1 Like