Hello, i have the problem that i want to spawn a Package with a script when a GUI button is Pressed, i have tried to fire a BindableEvent so a normal script spawn the package, But nothing happens!
i found out that the Event not fired, so my Question is if it is possible to fire a BindableEvent from a Local Script.
Script:
script.Parent.Spawning.Event:Connect(function()
local InsertService = game:GetService("InsertService")
local model = InsertService:LoadAsset(script.Parent.FahrzeugID)
model.Parent = workspace.Clones
end)
Local Script:
local Player = game.Players.LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Visible = false
script.Parent.Parent.Parent.Spawning:Fire()
end)
yes, but only if the bindable is in a location accessible to the client and only if the subscriber has called connect on the client, if the bindable is in serverstorage, or your handler is connected in a server script, nothing will happen, if you need client - server communication, use Remote Events.
Create a BindableEvent. Change “Spawning” to whatever you name it. Server Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local InsertService = game:GetService("InsertService")
local spawningEvent = ReplicatedStorage:WaitForChild("Spawning")
spawningEvent.Event:Connect(function(fahrzeugID)
local model = InsertService:LoadAsset(fahrzeugID)
model.Parent = workspace.Clones
end)
Local Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Player = game.Players.LocalPlayer
local spawningEvent = ReplicatedStorage:WaitForChild("Spawning")
script.Parent.MouseButton1Click:Connect(function()
script.Parent.Parent.Visible = false
spawningEvent:Fire(script.Parent.FahrzeugID)
end)