Hi everyone, I’ve recently been creating my own game (a semi-rp wolf game) but I’m having trouble with creating a functional script that enables and disables my fire part whilst using a Proximity Prompt to trigger the script (my aim was for the player to hold F on the Fireplace Asset and then the fire will turn on/off when the player does this.)
I was given a script to use but it hasn’t been working, not sure if it’s something to do with where the script is placed or if it just doesn’t work anymore but when using the Proximity Prompt it doesn’t turn the fire on or off. It just does nothing. The script I’ve input is as follows:
local fire = workspace:WaitForChild("FirePart").Fire -- LOCAL SCRIPT IN STARTERPLAYERSCRIPTS (ONLY PLAYER CAN SEE)
local prox = workspace.FirePart.ProximityPrompt
prox.Triggered:Connect(function()
if fire.Enabled == true then
fire.Enabled = false
else
fire.Enabled = true
end
end)
Here is also an image of where I’ve placed the script. The fireplace asset with the Fire Part in it is in Workspace.
Solutions wise I have searched both YouTube, here and tried asking for assistance in Discord servers but none of them have worked.
Hello! Is the fire part already in the workspace to begin with or does a player summon it?
Also a simplified script for this is:
local fire = workspace:WaitForChild("FirePart").Fire
local prox = workspace.FirePart.ProximityPrompt
prox.Triggered:Connect(function()
fire.Enabled = not fire.Enabled
end)
Yes, the Fire Part is already in Workspace but it’s inside of my Fireplace asset/model which I was thinking maybe that was where the issue is but not sure. Also, I will go ahead and adjust the script to what you suggested now and see if that works!
local fireplaceAsset = workspace:WaitForChild("FireplaceAsset")
local fire = asset:WaitForChild("FirePart").Fire
local prox = asset.ProximityPrompt
prox.Triggered:Connect(function()
fire.Enabled = not fire.Enabled
end)
I believe the problem is that you were trying to access the firepart from the workspace, but it is parented to fireplaceasset, which contains the firepart and the proximity prompt.
Wait, I found the problem, needed to change the asset part of the script you provided but it’s all working now, will only the player who has enabled the fire be able to see it though or will it be every player?