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

:Fire() Will Not Fire The Bindable Event??

Asked by 2 years ago

So I Am reposting this question because nobody answered that.

My Script won't fire the bindable event. Both of the scripts are in the workspace.

First script:

local this = script.Parent.Parent

local Btns = this.Buttons

local Events = this.Events
local A1 = function()
    local PassedValue = Btns.ButtonF1.Floor.Value
    Events.DoorOpen:Fire(PassedValue)
    print("Success")
end
local A2 = function()
    local PassedValue = Btns.ButtonF2.Floor.Value
    Events.DoorOpen:Fire(PassedValue)
    print("Success")
end

Btns.ButtonF1.ClickDetector.MouseClick:Connect(A1)
Btns.ButtonF2.ClickDetector.MouseClick:Connect(A2)

Second Script:

local this = script.Parent.Parent

local Btns = this.Buttons
local Doors = this.Doors

local Events = this.Events

local Settings = require(this.Scripts.LiftSettings)

local TweenService = game:GetService("TweenService")


Events.DoorOpen.Event:Connect(function(passedValue)
    print("BindableEvent Received!")
    print("Passed value is: " .. passedValue)
    print("Success | Doors")
    Activate(passedValue)
end)

function Open1()
    local currentpart1 = Doors.DoorF1
    local goal = {}
    goal.Position = Vector3.new(-155.909, 7.399, -156.228)
    goal.Size = Vector3.new(0.315, 12.794, 0.284)

    local tweenInfo = TweenInfo.new(
        Settings.DoorTime, -- Time the tween takes
        Enum.EasingStyle.Quad, -- EasingStyle
        Enum.EasingDirection.Out, -- EasingDirection
        0, -- How many times you want it to repeat
        false, -- Reverse
        0 -- Delay
    )
    local Tween = TweenService:Create(currentpart1, tweenInfo, goal)
    Tween:Play() -- Starts the tween

end
function Open2()
    local currentpart1 = Doors.DoorF1
    local goal = {}
    goal.Position = Vector3.new(-155.909, 28.621, -151.738)
    goal.Size = Vector3.new(0.315, 12.794, 0.284)

    local tweenInfo = TweenInfo.new(
        Settings.DoorTime, -- Time the tween takes
        Enum.EasingStyle.Quad, -- EasingStyle
        Enum.EasingDirection.Out, -- EasingDirection
        0, -- How many times you want it to repeat
        false, -- Reverse
        0 -- Delay
    )
    local Tween = TweenService:Create(currentpart1, tweenInfo, goal)
    Tween:Play() -- Starts the tween
end
function Activate(floor)
    if floor == "Floor1" then
        Open1()
        print("A1")
    elseif floor == "Floor2" then
        Open2()
        print("A2")
end

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

NOTE: I just realized after a while that I mixed up Bindable Events and Remote Events. You can try using Remote Events and apply the method below, but if you want to stick with Bindable Events, you can just go ahead and ignore this answer.

When firing a RemoteEvent, you must use :FireServer(), :FireClient(), or :FireAllClients(), depending on your use case. I'm going to suppose that these are both server scripts, so in your first script Line 8 and Line 13, simply change both of the ":Fire()" to ":FireServer()".

To recieve an event, you can use a special instance event called "OnServerEvent" and "OnClientEvent". Since I am imposing that these are server events, in the second script you should change the specified event on Line 13 ".Event" to ".OnServerEvent".

First Script Code:

local this = script.Parent.Parent

local Btns = this.Buttons

local Events = this.Events
local A1 = function()
    local PassedValue = Btns.ButtonF1.Floor.Value
    Events.DoorOpen:FireServer(PassedValue)
    print("Success")
end
local A2 = function()
    local PassedValue = Btns.ButtonF2.Floor.Value
    Events.DoorOpen:FireServer(PassedValue)
    print("Success")
end

Btns.ButtonF1.ClickDetector.MouseClick:Connect(A1)
Btns.ButtonF2.ClickDetector.MouseClick:Connect(A2)

Second Script Code:

local this = script.Parent.Parent

local Btns = this.Buttons
local Doors = this.Doors

local Events = this.Events

local Settings = require(this.Scripts.LiftSettings)

local TweenService = game:GetService("TweenService")


Events.DoorOpen.OnServerEvent:Connect(function(passedValue)
    print("BindableEvent Received!")
    print("Passed value is: " .. passedValue)
    print("Success | Doors")
    Activate(passedValue)
end)

function Open1()
    local currentpart1 = Doors.DoorF1
    local goal = {}
    goal.Position = Vector3.new(-155.909, 7.399, -156.228)
    goal.Size = Vector3.new(0.315, 12.794, 0.284)

    local tweenInfo = TweenInfo.new(
        Settings.DoorTime, -- Time the tween takes
        Enum.EasingStyle.Quad, -- EasingStyle
        Enum.EasingDirection.Out, -- EasingDirection
        0, -- How many times you want it to repeat
        false, -- Reverse
        0 -- Delay
    )
    local Tween = TweenService:Create(currentpart1, tweenInfo, goal)
    Tween:Play() -- Starts the tween

end
function Open2()
    local currentpart1 = Doors.DoorF1
    local goal = {}
    goal.Position = Vector3.new(-155.909, 28.621, -151.738)
    goal.Size = Vector3.new(0.315, 12.794, 0.284)

    local tweenInfo = TweenInfo.new(
        Settings.DoorTime, -- Time the tween takes
        Enum.EasingStyle.Quad, -- EasingStyle
        Enum.EasingDirection.Out, -- EasingDirection
        0, -- How many times you want it to repeat
        false, -- Reverse
        0 -- Delay
    )
    local Tween = TweenService:Create(currentpart1, tweenInfo, goal)
    Tween:Play() -- Starts the tween
end
function Activate(floor)
    if floor == "Floor1" then
        Open1()
        print("A1")
    elseif floor == "Floor2" then
        Open2()
        print("A2")
end
0
Oh no, I mixed up Bindable Events and Remote Events... :( PaleNoobs 37 — 2y
0
I'll try. Brioche_Noodle 45 — 2y
Ad

Answer this question