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
7 years ago

This is the script in serverscriptservice

1game.Players.PlayerAdded:connect(function(player)
2 
3local rmtevent = game:GetService('ReplicatedStorage'):WaitForChild('IsSpawn')
4 
5 
6rmtevent.OnServerEvent:connect(function()
7game.Lighting.GunMagsStorage.GunStorage.Deagle:Clone().Parent = game.Players[player.Name].Backpack
8end)
9end)

This is the script in startergui which fires the remote event

01local rmtevent = game:GetService('ReplicatedStorage'):WaitForChild('IsSpawn')
02local isSpawner = {["Prestory"] = true, ["iiFrzyii"] = true, ["dom1107"] = true,["MacRRP"]= true,["RobSnappin"]= true,["A_TrueGentlemen"]= true}
03 
04function onChatted(message, player)
05    if message == "/sg Gucci" and isSpawner[player.Name] then
06    rmtevent:FireServer()
07end
08end
09game.Players.PlayerAdded:connect(function(player)
10    player.Chatted:connect(function(message) onChatted(message, player) end)
11end)

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 7 years ago
Edited 7 years ago

the serverscriptservice one is wrong, here

1local rmtevent = game:GetService('ReplicatedStorage'):WaitForChild('IsSpawn')
2 
3rmtevent.OnServerEvent:connect(function(player)
4    game.Lighting.GunMagsStorage.GunStorage.Deagle:Clone().Parent = player.Backpack
5end)

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

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

Answer this question