Hello devs, I’m looking for a bit of help! I am trying to fire a remote event on the client when the player sits on a normal seat. The problem is that I don’t receive any error in the output and the actions that should be performed when the event is fired do not occur.
Here are my scripts:
Script inside a Proximity Prompt of a Seat in Workspace
local proximity = script.Parent
local bedSeat = proximity.Parent
local players = game:GetService("Players")
local rEvents = game.ReplicatedStorage:WaitForChild("TaskREvents")
--disable proximity if someones using the seat
bedSeat:GetPropertyChangedSignal("Occupant"):Connect(function()
if bedSeat.Occupant then
proximity.Enabled = false
else
proximity.Enabled = true
end
end)
local function onSeated(isSeated, seat)
if isSeated then
if seat:GetAttribute("typeOfSeat") then
local currentSeatType = seat:GetAttribute("typeOfSeat")
if currentSeatType == "bed" then
print("player is seated on a bed")
local plyr = players:GetPlayerFromCharacter(seat.Occupant.Parent)
rEvents.CompleteSleep:FireClient(plyr)
end
end
else
print("player is not seated")
end
end
local function onProximityPrompted(player)
bedSeat:Sit(player.Character.Humanoid)
player.Character.Humanoid.Seated:Connect(onSeated)
end
--main seat function
proximity.Triggered:Connect(onProximityPrompted)
LocalScript inside StarterGUI
game.ReplicatedStorage.TaskREvents.CompleteSleep.OnClientEvent:Connect(function()
print("hey")
end)
Hope I can get some help Thanks!