You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want so if the mouse is hovering over a interactable part a billboard gui will show a text of what the player can do with it -
What is the issue? Include screenshots / videos if possible!
When the player respawn the billboard gui doesn’t appear but other things are functional like normal -
What solutions have you tried so far?
I tried printing the billboard gui properties but everything printed is what i expected
Client Script
local players = game.Players
local rs = game.ReplicatedStorage
local uis = game:GetService("UserInputService")
local mouse = players.LocalPlayer:GetMouse()
local playerGui = players.LocalPlayer.PlayerGui
local mainGui = playerGui:WaitForChild("MainGui")
local interactGui = mainGui:FindFirstChild("InteractGui")
local text = interactGui:FindFirstChild("InteractText")
local keycode = nil
local target = nil
local statusChanged = nil
local floodEvent = rs.Events:WaitForChild("TurnFloodlight")
local character = players.LocalPlayer.Character
local function textF()
if target:GetAttribute("Status") then
text.Text = target:GetAttribute("TurnOff")
else
text.Text = target:GetAttribute("TurnOn")
end
end
local function onOff()
target = mouse.Target
statusChanged = target:GetAttributeChangedSignal("Status")
interactGui.Adornee = target
interactGui.Enabled = true
keycode = target:GetAttribute("KeyCode")
local attributes = target:GetAttributes()
textF()
statusChanged:Connect(textF)
end
local interacttype = {
["OnOff"] = onOff,
}
local function onInputChange()
if mouse.Target and not character:FindFirstChildOfClass("Tool") then
local interType = mouse.Target:GetAttribute("InteractType")
if interType then
interacttype[interType]()
else
target = nil
interactGui.Adornee = nil
interactGui.Enabled = false
end
else
interactGui.Adornee = nil
interactGui.Enabled = false
end
end
local function inputEnd(input)
if keycode then
if input.KeyCode == Enum.KeyCode[keycode] then
if mouse.Target then
target = mouse.Target
if target then
local distanceFromTarget = game.Players.LocalPlayer:DistanceFromCharacter(target.Position)
if distanceFromTarget < 10 then
floodEvent:FireServer(target, target:GetAttribute("Status"))
end
end
end
end
end
end
uis.InputChanged:Connect(onInputChange)
uis.InputEnded:Connect(inputEnd)
character.ChildAdded:Connect(function(child)
if child:IsA("Tool") then
onInputChange()
keycode = nil
end
end)
character.ChildRemoved:Connect(function(child)
if child:IsA("Tool") then
onInputChange()
end
end)
Server script
local rs = game.ReplicatedStorage
local floodEvent = rs.Events:WaitForChild("TurnFloodlight")
local function onFloodEvent(plyr, floodLight, status)
local model = floodLight:FindFirstAncestorOfClass("Model")
if model then
local lightPart = model:FindFirstChild("LightPart")
if lightPart then
if status == true then
lightPart.SpotLight.Brightness = 0
floodLight:SetAttribute("Status", false)
elseif status == false then
lightPart.SpotLight.Brightness = 40
floodLight:SetAttribute("Status", true)
end
end
end
end
floodEvent.OnServerEvent:Connect(onFloodEvent)
Also the interactable part attributes
Btw: I’m using floodlight just as a test, also thanks in advance