I’m trying to make it so at only I can have somethings but it doesn’t work. What’s gone wrong?
game.Players.PlayerAdded:Connect(function(plr)
if game.Players.LocalPlayer.UserId == “1505268552” then
game.Lighting.Shotgun:Clone().Parent = plr:WaitForChild(“Backpack”)
game.Players.LocalPlayer.PlayerGui.GameUI.STS_Settings.SprintSpeed.Value = “30”
end
end)
You cannot access the LocalPlayer variable in the server. Try this out instead:
local PS = game:GetService("Players")
local LT = game:GetService("Lighting")
PS.PlayerAdded:Connect(function(player)
if player.UserId == 1505268552 then
local shotgun = LT.Shotgun:Clone() do
shotgun.Parent = player.Backpack
end
local sprintSpeed = player.PlayerGui.GameUI.STS_Settings:FindFirstChild("SprintSpeed")
if sprintSpeed then
sprintSpeed.Value = 30 -- replace with "30" if sprintSpeed is a StringValue
end
end
end)
game.Players.PlayerAdded:Connect(function(plr)
if plr.UserId == 1505268552 then
game.Lighting.Shotgun:Clone().Parent = plr:WaitForChild("Backpack")
plr.PlayerGui.GameUI.STS_Settings.SprintSpeed.Value = 30
end
end)
local PS = game:GetService("Players")
local LT = game:GetService("Lighting")
PS.PlayerAdded:Connect(function(player)
if player.UserId == 1505268552 then
local shotgun = LT.Shotgun:Clone()
shotgun.Parent = player.Backpack
local sprintSpeed = player.PlayerGui.GameUI.STS_Settings:FindFirstChild("SprintSpeed")
if sprintSpeed then
sprintSpeed.Value = 30 -- replace with "30" if sprintSpeed is a StringValue
end
end
end)
Does this help?
Edit: It’s just @Downrest’s code but I modify the shotgun part a bit.