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

Why won't this give players a Pistol? [SOLVED]

Asked by 10 years ago
game.Workspace.Guns.Changed:connect(function(t)
    if t == "Start" then
        local Player = game:GetService("Players").LocalPlayer
        local Item = game:GetService("ReplicatedStorage").Pistol:Clone()
        Item.Parent = Player.Backpack
    end
end)

In another script, I have something to change the Gun Value to "Start"

Oh, its in LocalScript too

0
Anything in the output? M39a9am3R 3210 — 10y
0
No, nothing NinjoOnline 1146 — 10y

4 answers

Log in to vote
1
Answered by
jakedies 315 Trusted Moderation Voter Administrator Community Moderator
10 years ago

Is filtering enabled? If so, make sure you are changing the Guns value client-side. If not then add some prints to see where the script stops. (Like 1 every line). So something like:

game.Workspace.Guns.Changed:connect(function(t)
    print("Value Changed")
    if t == "Start" then
        print("Value = Start")
        local Player = game:GetService("Players").LocalPlayer
        local Item = game:GetService("ReplicatedStorage").Pistol:Clone()
        print("Player defined, item cloned")
        Item.Parent = Player.Backpack
        print("Item parented")
    end
end)
0
Ok, so nothing is coming through, so I am guessing that the LocalScript isnt even working. Any ideas? Is it possible to do the same thing in just a normal script? NinjoOnline 1146 — 10y
0
Hm, where is the local script located? In StarterGui? jakedies 315 — 10y
0
No, its in Workspace NinjoOnline 1146 — 10y
0
That's the problem. Put it in StarterGui jakedies 315 — 10y
View all comments (4 more)
0
so nothign was wrong with script, just has to be placed in starterGui? NinjoOnline 1146 — 10y
0
Yup jakedies 315 — 10y
0
for some reason now, if a player dies, they dont get their gun back. Anyway to make them so once they get the gun it stays with them until the other script removes the gun NinjoOnline 1146 — 10y
0
Put it in there StarterGear as well. jakedies 315 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

Try putting it in ServerStorage.

0
That doesn't work for LocalScripts. Descendants of ServerStorage are virtually invisible to LocalScripts. M39a9am3R 3210 — 10y
0
yeah it didnt work NinjoOnline 1146 — 10y
0
Can you answer my question? :l CharcterKaiser 0 — 10y
0
Why are you asking that on here? NinjoOnline 1146 — 10y
Log in to vote
0
Answered by 10 years ago

ServerScriptService will work?

0
No it wont cause the pistol aint a script NinjoOnline 1146 — 10y
Log in to vote
0
Answered by 10 years ago

Have you tryed putting

game.Workspace.Guns.Changed:connect(function(t)
    if t == "Start" then
        local Player = game:GetService("Players").LocalPlayer
        local Item = game:GetService("Lighting").Pistol:Clone() -- Changed to lighting. Remember to put the gun in there as well.
        Item.Parent = Player.Backpack
    end
end)

Answer this question