Im trying to get a click detector to fire on the server because that seems like the only way the click detector will work. But when i test it nothing happens
i dont get any errors or anything in the output besides the "re works"
--Script
local button = script.Parent local click = script.Parent:WaitForChild("Click") local RE = script.Parent:WaitForChild("ClickEvent") click.MouseClick:Connect(function(player) RE:FireClient(player) if RE then print("re works") end end)
--Local Script
local button = script.Parent local click = script.Parent:WaitForChild("Click") local Remote = script.Parent:WaitForChild("ClickEvent") local TS = game:GetService("TweenService") local TI = TweenInfo.new( 1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, true, 0 ) local buttonprop = { Color = Color3.fromRGB(255,255,255) } local Tween = TS:Create(button,TI,buttonprop) local function buttonPressed(player) print("Test") end Remote.OnClientEvent:Connect(buttonPressed)
So the issue I see is that a remote event has to be inside the ReplicatedStorage
and that the local script is not inside the player's scripts
Try something like this:
--Script (inside of Button)
local RepStore = game.ReplicatedStorage local button = script.Parent local click = script.Parent:WaitForChild("Click") local RE = RepStore:WaitForChild("ClickEvent") click.MouseClick:Connect(function(player) RE:FireClient(player, button) end)
-- Local Script (Inside StarterPlayer.StarterPlayerScripts)
local RepStore = game.ReplicatedStorage local RE = RepStore:WaitForChild("ClickEvent") local TS = game:GetService("TweenService") local TI = TweenInfo.new( 1, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, true, 0 ) local buttonprop = { Color = Color3.fromRGB(255,255,255) } local function buttonPressed(player, button) print("Test") local Tween = TS:Create(button,TI,buttonprop) Tween:Play() end Remote.OnClientEvent:Connect(buttonPressed)
Let me know if there's any issues :)
Learn more about Remote Events here
Learn More about TweenService here