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

I am having trouble making a script that gives a player a sword any help?

I am scripting a Swordgiver that when a button is pressed it will give a sword. But I do not know what to put into the player variable because Players.Localplayer only works on local scripts I am doing this with a text button. if there isn't a way to do this can someone tell me another way

local ClassicSword = game.ServerStorage.ClassicSword local part = script.Parent local canGet = true

local function onTouch() local Player = local Char = Player.Character local SwordClone = ClassicSword:Clone() SwordClone.Parent = Char end part.MouseButton1Click:Connect(onTouch)

3 comments

0

Are you using a Text Button on a SurfaceGUI?

0

Why are you using MouseButton1Click on a part?

0

the part is just a variable equal to the text button

1 answer

Just use remote events bro. Set a local script that gets the player and if the text button clicked fire the remote event with the args player. then set a server event that directly clones your sword to the other players backpack. EXAMPLE: Local script:

script.Parent.MouseButton1Click:Connect(function(plr)
script.Parent.LOWIQ:FireServer(plr) (just a example of remote event name)
end)

ServerScript:

script.Parent.LOWIQ.OnServerEvent:Connect(function(plr)
local Tool = game.ServerStorage.ClassicSword
Tool:Clone().Parent = plr:FindFirstChild("Backpack")
end)

1 comment

0

I already figured that out

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