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

Remote Event In Game Not Firing OR Being Picked Up??. Help!!

Asked by 4 years ago

Making A Simple Simulator game on roblox and im using remote events to buy tools for cash (or as i refer to it as "Halopower" )

and the button detects its being clicked but does not fire the event OR the server script does not pick it up

local script firing it:

local btnText = script.Parent.TextLabel
local btn = script.Parent
local repStorage = game:GetService("ReplicatedStorage")


btn.MouseButton1Click:Connect(function()
    repStorage.Remotes.BuyMolten:FireServer()
end)

server script "suppose to be" detecting it

local ReplicatedStorage = game:GetService('ReplicatedStorage')
local remoteEvent = ReplicatedStorage:WaitForChild("BuyMolten")
local btnText = game.Players:WaitForChild("PlayerGui").ShopUI.Frame.BuyMolten.TextLabel.Text
local toolFolder = game.ServerStorage.ShopItems
local toolPrice = 150

remoteEvent.OnServerEvent:Connect(function(player)
    print("FireServerDetectedFromBuyTool")
    if player.leaderstats.Halopower.Value >= toolPrice then
        player.leaderstats.Halopower.Value = player.leaderstats.Halopower - toolPrice
    toolFolder:FindFirstChild("Molten Halo"):Clone().Parent = player.Backpack
    end
end)



if needed i will include code from other parts of the game like data stores remotes stats and more.

thanks, Joe Engo (aka MightBeAHaxxer / MightBeAScripter)

0
local script is in startergui and the server script is in SSS (ServerScriptService) i will add waitforchild now MightBeAHaxxer 24 — 4y
0
Also if I'd advise against giving out your real name on this website. Rinextel 291 — 4y
0
not my real name just my discord :D MightBeAHaxxer 24 — 4y

1 answer

Log in to vote
0
Answered by
Rinextel 291 Moderation Voter
4 years ago

Hello MightBeAHaxxer!

Though I am not exactly sure what is wrong due to the lack of information, I believe it is from one of these issues;

A) The ServerScript is somewhere the server cannot access.

B) The LocalScript is somewhere the player cannot access.

C) The button is not a textbutton.


In of a TextButton, you should insert a local script! The contents of the localscript should be whats below.

local button = script.Parent --The TextButton object
local repStorage = game:GetService('ReplicatedStorage')
local buyMolten = repStorage:WaitForChild('Remotes'):WaitForChild('BuyMolten')

button.MouseButton1Click:Connect(function()

    print('Owch! That click hurt!')

    buyMolten:FireServer()

    print('All you had to do was ask :(')
end)    


Now, inside of a regular Script (not local) inside of ServerScriptService the contentsshould be as follows.

local repStorage = game:GetService('ReplicatedStorage')
local buyMolten = repStorage:WaitForChild('Remotes'):WaitForChild('BuyMolten')

buyMolten.OnServerEvent:Connect(function(PlayerObject)
    print('Well we heard that one!')
end)

Therefore, when you press the TextButton the output should be as follows:

Owch! That click hurt!

All you had to do was ask :(

Well we heard that one!

0
If this does not work, please show me a screenshot of the Output bar. Further, show me the hierarchy (StarterGui & SSS). Rinextel 291 — 4y
Ad

Answer this question