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

My FE Shop Gui Wont Work? (Event Wont Fire)

Asked by
Nikkulaos 229 Moderation Voter
7 years ago

I am working on a shop gui, and everything works, except the whole server script. It acts as if i didnt fire the event, and doesnt print anything from the script either. The scripts are also not disabled, so idk whats going on. And since there are no errors in the input, it makes it a lot harder.

This is what i got so far:

The layout is like this: Button > Server Script, Local Script, and Remote Event (They are all inside the button)

Local Script:

local BuyEventOn = script.Parent:WaitForChild("BuyEvent")

local Player = game.Players.LocalPlayer
script.Parent.MouseButton1Down:Connect(function(click)

if Player:WaitForChild("leaderstats"):FindFirstChild("Money").Value > = script.Parent:WaitForChild("Cost").Value and Player:FindFirstChild(script.Parent.Name).Value == 0 then

BuyEventOn:FireServer()
print("1")
end
end)

Server Script:


local BuyEventOn = script.Parent:WaitForChild("BuyEvent") local function BuyEvent1(Player) print("2") Player:WaitForChild("leaderstats"):FindFirstChild("Money").Value = Player:WaitForChild("leaderstats"):FindFirstChild("Money").Value - script.Parent:WaitForChild("Cost").Value Player:FindFirstChild(script.Parent.Name).Value = 1 script.Parent.BackgroundColor3 = Color3.new(0, 255, 0) end BuyEventOn.OnServerEvent:Connect(BuyEvent1)

Im so confused, and im wondering if i did something wrong. And i know its not having anything to do with the Background color or the Leaderstats part, cause if it was then why isnt the print("2") part working? If you can help then please do! Thanks!

0
Hello Nikkulai, have you tried debugging your local script? Add an else statement under the first if statement in your Local script and add a print ("you dont have enough money for this item."). This is checking if your first conditional statement could be false. :) Impacthills 223 — 7y
0
Ok, thanks! :D Nikkulaos 229 — 7y
0
If it happens to work/not work, then ill tell you. Nikkulaos 229 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

I think insted of using a remote event use a remote function because i think Remote Event can't really access player guis only player data such as player, intvalues or more.

0
Thanks you a ton! Lol, i totally got them mixed up Nikkulaos 229 — 7y
Ad

Answer this question