server script
function blaster1(player, blaster) if player then local clone = blaster:Clone() clone.Parent = player.Backpack end end BlasterEvent.OnServerEvent:Connect(blaster1())
local script that is under a button gui in starter gui
local player = game.Players.LocalPlayer local leaderstats = player:WaitForChild("leaderstats") local event = game.ReplicatedStorage.Equips local weapon = false local guns = game.ReplicatedStorage.Weapons local E1 = player.PlayerScripts:WaitForChild("E1") local co1 = coroutine.create(function() while wait() do if E1.Blaster.Value == true then weapon = true script.Parent.BackgroundColor3 = Color3.new(0, 255, 0) script.Parent.Text = "Equiped" script.Parent.Parent.SMG.Visible = false script.Parent.Parent.AK.Visible = false script.Parent.Parent.Bow.Visible = false script.Parent.Parent.Grenade.Visible = false script.Parent.Parent.Mini.Visible = false script.Parent.Parent.Rail.Visible = false script.Parent.Parent.Rocket.Visible = false script.Parent.Parent.Sniper.Visible = false else end end end) coroutine.resume(co1) script.Parent.MouseButton1Click:Connect(function() if weapon == false then if leaderstats.Heads.Value >= 120 then E1.Blaster.Value = true weapon = true script.Parent.BackgroundColor3 = Color3.new(0, 255, 0) script.Parent.Text = "Equiped" script.Parent.Parent.SMG.Visible = false script.Parent.Parent.AK.Visible = false script.Parent.Parent.Bow.Visible = false script.Parent.Parent.Grenade.Visible = false script.Parent.Parent.Mini.Visible = false script.Parent.Parent.Rail.Visible = false script.Parent.Parent.Rocket.Visible = false script.Parent.Parent.Sniper.Visible = false else workspace.Error:Play() end elseif weapon == true then weapon = false E1.Blaster.Value = false script.Parent.BackgroundColor3 = Color3.new(255,0,0) script.Parent.Text = "UnEquiped" script.Parent.Parent.SMG.Visible = true script.Parent.Parent.AK.Visible = true script.Parent.Parent.Bow.Visible = true script.Parent.Parent.Grenade.Visible = true script.Parent.Parent.Mini.Visible = true script.Parent.Parent.Rail.Visible = true script.Parent.Parent.Rocket.Visible = true script.Parent.Parent.Sniper.Visible = true end end) local blaster = game.ReplicatedStorage.Weapons.Blaster local co = coroutine.create(function() game.ReplicatedStorage.blaster:FireServer(blaster) end) event.RoundOn.Changed:Connect(function() print(coroutine.status(co)) coroutine.resume(co) end)
i have had a problem making an equiping system for weeks! please help
Hello, ProAimBoi! The problem is that you called the function while connecting it to an event. Try this:
local function blaster1(player, blaster) if player then local clone = blaster:Clone() clone.Parent = player.Backpack end end BlasterEvent.OnServerEvent:Connect(blaster1)
Please upvote and accept this answer if it helped you.