Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to i get this to work in a public server(this is in a localscript)?

Asked by 6 years ago
Edited 6 years ago
local re = game:GetService("ReplicatedStorage")
local gun = re:WaitForChild("GunOne")
local player = game.Players.LocalPlayer
script.Parent.MouseButton1Down:connect(function()
    local clonedgun = gun:Clone()
    clonedgun.Parent = player.Backpack
end)

1 answer

Log in to vote
0
Answered by 6 years ago

Since you are using a LocalScript, you should use your variable, "player" aswell as identify the player's mouse in order to trigger an event.


local re = game:GetService("ReplicatedStorage") local gun = re:WaitForChild("GunOne") local player = game.Players.LocalPlayer local m = player:GetMouse()

m.Button1Down:connect(function(m) local clonedgun = gun:Clone() clonedgun.Parent = player.Backpack end)


Ad

Answer this question