Hey! I’ve been recently working on a riot script, and I have come to a little problem. Once the riot starts, player normally gets a weapon cloned into his inventory (backpack), without any problems. However, once he respawns, he doesn’t get it again, which he is meant to.
Part of the script:
local function giveWeapon()
if game.ReplicatedStorage.IsRiotOngoing.Value == true then
if player.Team == game.Teams.Civilian then
script.AKM:Clone().Parent = player.Backpack
end
end
end
game.Players.PlayerAdded:Connect(function()
player.CharacterAdded:Connect(function()
wait(0.5)
giveWeapon()
end)
end)
use parameters on the giveWeapon() function and use them when you call it
local function giveWeapon(player)
if game.ReplicatedStorage.IsRiotOngoing.Value == true then
if player.Team == game.Teams.Civilian then
script.AKM:Clone().Parent = player.Backpack
end
end
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
wait(0.5)
giveWeapon(player)
end)
end)
I can’t make it a server script, as there is a OnClientEvent() function. Do you think separating this script from the OnClientEvent() function and making it a server script would help?