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

TextButton Won't give Tools?

Asked by
tre821 25
8 years ago

Okay so what I'm trying to do here is that when a player clicks a text button on the screen, tools are given to the player. When I click play in the studio, it works just fine, the tools are given to the player. However, when I run it as a normal place and press play, none of the Text Buttons (except for a sprint and walk button I made) do anything. Could someone tell me what's wrong with this? Script for the text button:

function giveTools()
    local tools1 = game.ServerStorage.SnowGolemMagic.SnowBall:clone()
    local tools2 = game.ServerStorage.SnowGolemMagic.SnowShell:clone()
    local tools3 = game.ServerStorage.SnowGolemMagic.SnowStorm:clone()
    local tools4 = game.ServerStorage.SnowGolemMagic.SnowFloor:clone()
    local tools5 = game.ServerStorage.SnowGolemMagic.GolemForm:clone()
    tools1.Parent = game.Players.LocalPlayer.Backpack
    tools2.Parent = game.Players.LocalPlayer.Backpack
    tools3.Parent = game.Players.LocalPlayer.Backpack
    tools4.Parent = game.Players.LocalPlayer.Backpack
    tools5.Parent = game.Players.LocalPlayer.Backpack
    script.Disabled = true  --So the button can't be pressed twice
end

script.Parent.MouseButton1Click:connect(giveTools) --Run the function

Explorer: http://i.imgur.com/MQ4Wlsd.png PS. I only recently learned how to use tables so that's why I didn't use the get children function and just did it all manually

0
Make sure that the script is in a local script. That's the only issue that I see Scootakip 299 — 8y

1 answer

Log in to vote
-1
Answered by 8 years ago

Hey! I recently ran into this problem earlier. I Can help you with that. Okay here's the problem with that. You're trying to clone tools that don't exist on the Client side of the game. Things stored in the Server Storage doesn't pass on to the Client side , primarily Because it's a SERVERstorage. The things stored in there don't clone onto the Client.

So..

I recommend you to create a folder in the StarterPack and Insert the tools in there. Don't Worry the tools won't be in their Inventory just stored away.

Here's the script that I changed for you:

-- I Changed the 'ServerStorage' dictionary to 'StarterPack' dictionary.  Please note that I added the 'Folder' as well.
function giveTools()
    local tools1 = game.StarterPack.Folder.SnowGolemMagic.SnowBall:clone()
    local tools2 = game.StarterPack.Folder.SnowGolemMagic.SnowShell:clone()
    local tools3 = game.StarterPack.Folder.SnowGolemMagic.SnowStorm:clone()
    local tools4 = game.StarterPack.Folder.SnowGolemMagic.SnowFloor:clone()
    local tools5 = game.StarterPack.Folder.SnowGolemMagic.GolemForm:clone()
    tools1.Parent = game.Players.LocalPlayer.Backpack
    tools2.Parent = game.Players.LocalPlayer.Backpack
    tools3.Parent = game.Players.LocalPlayer.Backpack
    tools4.Parent = game.Players.LocalPlayer.Backpack
    tools5.Parent = game.Players.LocalPlayer.Backpack
    script.Disabled = true  --So the button can't be pressed twice
end

script.Parent.MouseButton1Click:connect(giveTools) --Run the function

Now you have to change the the other scripts and make it similar to this one now to make it Work in the Client Side. You're Welcome!

Ad

Answer this question