I am trying to make a loadout system but for some reason, it will not give the player a weapon so I thought that there was an error but when I checked, nothing. Why is this happening? This is comming out of a regular script too.
Code:
script.Parent.MouseButton1Click:Connect(function()
local plr = script.Parent.Parent.Parent.Parent.Parent.Parent
local stat = plr.leaderstats.hiddenstats.Melee
if stat.Value == "Sword" then
local tool = game.ReplicatedStorage.Tools.Sword:Clone()
tool.Parent = plr.Backpack
end
end)
local Players =game:GetService("Players")
local Replicated = game:GetService("ReplicatedStorage")
local Player = Players.LocalPlayer
local Tools = Replicated:WaitForChild("Tools")
script.Parent.MouseButton1Click:Connect(function()
--fire a remote, do checks on the server
end)
I just saw you are using a normal script,
tho - I really suggest using a local script + remote to do that.
But if you keep insisting using a regular script, try this:
local Replicated = game:GetService("ReplicatedStorage")
local Tools = Replicated:WaitForChild("Tools")
script.Parent.MouseButton1Click:Connect(function()
local Player = script.Parent:FindFirstAncestorOfClass("Player")
local leaderstats = Player:WaitForChild("leaderstats"):WaitForChild("hiddenstats").melee
if leaderstats.Value =="Sword" then
print(leaderstats.Value)
end
end)