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

I want to make geargiver but when i touch the part it dosent give, help please?

Hello

I want to make a gear giver for my game, I Tried this script:

script.Parent.Touched:Connect(function(hit)
	local gear = script.Parent.Parent.Parent.ServerStorage.AK47
	local hum = hit.Parent:FindFirstChild("Humanoid")
	if (hum ~= nil) then
		local getParent = gear:Clone()
		getParent.Parent = game.Players.LocalPlayer
	end
end)

I need help with this, and i Hope i will Get some Help.

1 answer

LocalPlayer is a read-only property of Players that is set to the client's player that is currently playing the game locally. However, the property is only set LOCALLY and therefore cannot be retrieved from the server. The solution here is to get the player via the player (if a player was the one that triggered the Touched event), and set gearParent's parent to the player. An example of getting the player would be game.Player:GetPlayerFromCharacter(hit.Parent).

2 comments

0

You didn't really answer his question...

0

It's not working for me

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