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

My Remote event wont work when I try to activate when I click a button?

Asked by 2 years ago

Local script

local UserInputService = game:GetService("UserInputService")
local debounce = false
if debounce == false then
UserInputService.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.E then
        game.Players.LocalPlayer.PlayerGui.e.Frame.ePower.Visible = false
        script.EventPepporni:FireServer()
        local debounce = true
        wait(3)
            local debounce = false
            game.Players.LocalPlayer.PlayerGui.e.Frame.ePower.Visible = true
    end 
    end)
end

Normal Script

script.Parent.EventPepporni.OnServerEvent(function()
    print("it worked!!")
    local plr = script.Parent.Parent.Name
    local plrpos = game.Workspace:FindFirstChild(plr.name)
    local part = Instance.new("Part")
    part.parent = game.Workspace
end)

2 answers

Log in to vote
0
Answered by
Ascarson4 138
2 years ago
script.Parent.EventPepporni.OnServerEvent(function()

This line should be

script.Parent.EventPepporni:OnServerEvent(function()

The error should have showed up in the debug console, you used dot instead of colon

if debounce == false then 
UserInputService.InputBegan:Connect(function(input)

The debounce if-statment should go under UserInputService.InputBegan:Connect(function(input))

Ad
Log in to vote
0
Answered by 2 years ago

I dont think scripts run while they are in replicated storage. Try parenting the script to serverscriptservice

Answer this question