--//Server Script:
function clicked(click)
print(click.Name)
inventEvent:FireClient(click,click.Name)
clickdetector:Destroy()
end
clickdetector.MouseClick:Connect(clicked)
I would try to go back to basics and just experiment with it on an empty test place.
This is what I have:
ServerScript
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CantAffordEvent = Instance.new("RemoteEvent", ReplicatedStorage)
CantAffordEvent.Name = "CantAffordEvent"
if Cost <= Money then
CantAffordEvent:FireClient(Player)
end
PlayerGuiScript
local Frame = script.Parent
--setup client listen
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CantAffordEvent = ReplicatedStorage:WaitForChild("CantAffordEvent")
--Start Offscreen
Frame.Position = UDim2.new(0.5, 0, 0, -300)
local function OnCantAffordFired() --brings up the gui
Frame:TweenPosition(UDim2.new(0.5, 0, 0.22, 0), nil, nil, 0.25, false) --my code to run
end
CantAffordEvent.OnClientEvent:Connect(OnCantAffordFired)
You’re working with a click detector. You can already connect the event on the client, and it’ll work just the same way. (except it only detects clicks made by the local player). Unless you want to be detecting more players locally, you don’t need a remote for this.
You are only sending one argument throught the RemoteEvent because the first one you set in the FireClient() is the player. The player argument doesn’t actually get sent through. This is what the parameters are: FireClient(Player, Arguemnts). For other referenecs please see this page: RemoteEvent | Documentation - Roblox Creator Hub
Here is the fixed code:
--//Server Script:
function clicked(click)
print(click.Name)
inventEvent:FireClient(click, click, click.Name)
clickdetector:Destroy()
end
clickdetector.MouseClick:Connect(clicked)