Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Refresh player onclick ?

local ClickDetector = script.Parent ClickDetector.MouseClick:Connect(function() game.Workspace.WoodenSword.Parent = game.StarterPack local player = game.Players.LocalPlayer player.Health = 0 end)

1 comment

0

Is this the full script? Also, use the lua button on the top, and paste your code between the lines.(this makes it much easier to read) After this, I may be able to help you.

2 answers

✓ Accepted answer

Hello there!

Issues

  1. LocalPlayer can't be used in a ServerScript as they run on a physical server, no the client.

  2. Use player.Backpack instead of game.StarterPack as StarterPack is the container for starter tools. The backpack is the container for the tools in a player.

How to fix it

Use the parameter of MouseClick, which is the player who clicked it. Then, load the character of that player using Player:LoadCharacter(), and then set the wooden sword's parent to the player's backpack.

Fixed Code

script.Parent.ClickDetector.MouseClick:Connect(function(player)
	player:LoadCharacter()
	workspace.WoodenSword.Parent = player.Backpack
end)

Please upvote and accept my answer if it helped.

script.parent.ClickDetector.MouseClick:Connect(function()
local Player = game.Players.LocalPlayer

local Char = Player.Character

Char:LoadCharacter()

end)

This discussion is preserved as it was. New answers, comments, and votes are closed.