Im scripting GUI where when you click a button, a folder of scripts are put into your backpack.
I made a test script, one server and one client, and i added a remote event to fire on server event but for some reason it isnt firing, no matter what i do
Position of everything
Code (Client)
local UIS = game:GetService("UserInputService")
local Move = script.Parent.Parent["Move 1"]
UIS.InputBegan:Connect(function(input, chat)
if chat then return end
if input.KeyCode == Enum.KeyCode.Q then
print("Q was pressed")
Move:FireServer()
end
end)
Code (Server)
local Move = script.Parent.Parent["Move 1"]
Move.OnServerEvent:Connect(function(plr)
print(plr.Name, "pressed Q")
end)
im not sure why the event wont fire, and there are no errors in the output. Help is appreciated, thank you for your time.
Scripts and local scripts don’t run in ReplicatedStorage. Move the local script to StarterGui or StarterPlayerScripts and move the script to ServerScriptService. You will have to change the code a bit to account for this.
Why are you placing them in replicatedstorage? I believe they won’t work correctly there, consider putting the serverscript in serverscriptservice and the localscript in StarterGui.
Firing the client requires a player parameter passed in the initial firing. Firing the server is different; It doesn’t require a player parameter, since it is firing for the server, not the player.
button.Activated:Connect(function()
local folder = game.ReplicatedStorage:WaitForChild("Kindness"):Clone()
print("Kindness was chosen!")
for i, v in pairs(parent:GetChildren()) do
if v:IsA("ImageButton") then
print(v.Name)
v.Active = false
----------------------------
local tween = TweenService:Create(v, TweenInfo.new(.5), {ImageTransparency = 1})
tween:Play()
----------------------------
end
end
----------------------------
tween:Play()
tween.Completed:Wait()
HealthGUI.Enabled = true
folder.Parent = player.Backpack
end)