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

Why won't tools clone to inventory with a Chatted function through fe?

Asked by
Prestory 1395 Moderation Voter
6 years ago

This is the script in serverscriptservice

game.Players.PlayerAdded:connect(function(player)

local rmtevent = game:GetService('ReplicatedStorage'):WaitForChild('IsSpawn')


rmtevent.OnServerEvent:connect(function()
game.Lighting.GunMagsStorage.GunStorage.Deagle:Clone().Parent = game.Players[player.Name].Backpack
end)
end)


This is the script in startergui which fires the remote event

local rmtevent = game:GetService('ReplicatedStorage'):WaitForChild('IsSpawn')
local isSpawner = {["Prestory"] = true, ["iiFrzyii"] = true, ["dom1107"] = true,["MacRRP"]= true,["RobSnappin"]= true,["A_TrueGentlemen"]= true}

function onChatted(message, player)
    if message == "/sg Gucci" and isSpawner[player.Name] then
    rmtevent:FireServer()
end 
end
game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(message) onChatted(message, player) end)
end)

This script is meant to check if there name is on the list then when they type /sg gucci a gun clones to there inventory for some reason it does not work and no error is given in the output may someone help thanks.

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

the serverscriptservice one is wrong, here

local rmtevent = game:GetService('ReplicatedStorage'):WaitForChild('IsSpawn')

rmtevent.OnServerEvent:connect(function(player)
    game.Lighting.GunMagsStorage.GunStorage.Deagle:Clone().Parent = player.Backpack
end)


OnServerEvent always has a default parameter, which is the player that fired the remote fixed starter gui script:

local isSpawner = {["Prestory"] = true, ["iiFrzyii"] = true, ["dom1107"] = true,["MacRRP"]= true,["RobSnappin"]= true,["A_TrueGentlemen"]= true}
game.Players.LocalPlayer.Chatted:connect(function(message)
    if isSpawner[game.Players.LocalPlayer.Name] and message == "/sg Gucci" then
        rmtevent:FireServer()
    end
end)
Ad

Answer this question