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 my script working
What is the issue? Include screenshots / videos if possible!
The script are not working
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I looked but it’s doesn’t what I’ve look into
I have generator script that placed inside generator model. When I run and test it’s works like normal but when I tried to put my generator model to another model or folder. The script are not working. This same as I tried to clone script to generator model too. The provlem is the script that detect Proximity Prompt triggered not working. But the print command i wrote in the first line of script works. Weird enough… I don’t know why. If you could help me it would be appreciated.
wait(5)
print("created generator script")
local Finished = false
script.Parent:WaitForChild("Position1").ProximityPrompt.Enabled = true
script.Parent:WaitForChild("Position2").ProximityPrompt.Enabled = true
script.Parent:WaitForChild("Position3").ProximityPrompt.Enabled = true
script.Parent:WaitForChild("Position1").ProximityPrompt.Script.Enabled = true
script.Parent:WaitForChild("Position2").ProximityPrompt.Script.Enabled = true
script.Parent:WaitForChild("Position3").ProximityPrompt.Script.Enabled = true
script.Parent.RequestFixing.Event:Connect(function(plr, part)
print("working on checking work")
if plr.Character.Stats.Fix.Value == false and plr.Character.Stats.Downed.Value == false then
if plr.Team == game.Teams.Survivors then
local closedetected = false
for i,otherplr in pairs(game.Teams.Survivors:GetPlayers()) do
if otherplr.Character ~= nil then
if otherplr.Character.Stats.Fix.Value == true then -- stats.fix is custom value for my game
if (part.Position - otherplr.Character.HumanoidRootPart.Position).Magnitude <= 1 then
closedetected = true
print("not able to fix")
end
end
end
end
if closedetected == false then
print("able to fix")
plr.Character.HumanoidRootPart.CFrame = part.CFrame
plr.Character.Stats.Fix.Value = true
script.Parent:WaitForChild("Generator").Interact:Play()
plr.PlayerGui.GeneratorProgress.Frame.Object.Value = script.Parent:WaitForChild("Stats").Progress
plr.PlayerGui.GeneratorProgress.Frame.RemoteObject.Value = script.Parent:WaitForChild("SuccessfullEvent")
end
end
end
end)
script.Parent.SuccessfullEvent.OnServerEvent:Connect(function(plrwhofixed)
if plrwhofixed.Character then
if plrwhofixed.Team == game.Teams.Survivors then
if plrwhofixed.Character:FindFirstChild("Stats").Fix.Value == true then
script.Parent:WaitForChild("Stats").Progress.Value = script.Parent:WaitForChild("Stats").Progress.Value + plrwhofixed.Character:FindFirstChild("Stats").GeneratorProgress.Value
end
end
end
end)
while true do -- detect once it finished
wait(0.1)
--print("loop works")
if script.Parent.Stats.Progress.Value >= 100 then
script.Parent:WaitForChild("Generator").SurfaceLight.Enabled = true
script.Parent:WaitForChild("Generator").SurfaceLight2.Enabled = true
script.Parent:WaitForChild("Generator").SurfaceLight3.Enabled = true
script.Parent:WaitForChild("Generator").SurfaceLight4.Enabled = true
script.Parent:WaitForChild("Position1").ProximityPrompt.Enabled = false
script.Parent:WaitForChild("Position2").ProximityPrompt.Enabled = false
script.Parent:WaitForChild("Position3").ProximityPrompt.Enabled = false
if Finished == false then
Finished = true
if game.ReplicatedStorage:FindFirstChild("RoundTimer").Time.Value > 120 then
game.ReplicatedStorage:FindFirstChild("RoundTimer").Time.Value = game.ReplicatedStorage:FindFirstChild("RoundTimer").Time.Value - 30
elseif game.ReplicatedStorage:FindFirstChild("RoundTimer").Time.Value > 60 then
game.ReplicatedStorage:FindFirstChild("RoundTimer").Time.Value = game.ReplicatedStorage:FindFirstChild("RoundTimer").Time.Value - 20
elseif game.ReplicatedStorage:FindFirstChild("RoundTimer").Time.Value > 0 then
game.ReplicatedStorage:FindFirstChild("RoundTimer").Time.Value = game.ReplicatedStorage:FindFirstChild("RoundTimer").Time.Value - 10
end
end
if script.Parent.Generator.Finished.IsPlaying == false then
script.Parent.Generator.Finished:Play()
end
for i,otherplr in pairs(game.Teams.Survivors:GetPlayers()) do
if otherplr.Character ~= nil then
if otherplr.Character.Stats.Fix.Value == true then
if (script.Parent.Position1.Position - otherplr.Character.HumanoidRootPart.Position).Magnitude <= 1 then
--print("de")
otherplr.PlayerGui.GeneratorProgress.Frame.Object.Value = nil
otherplr.PlayerGui.GeneratorProgress.Frame.RemoteObject.Value = nil
otherplr.Character.Stats.Fix.Value = false
end
end
end
end
for i,otherplr in pairs(game.Teams.Survivors:GetPlayers()) do
if otherplr.Character ~= nil then
if otherplr.Character.Stats.Fix.Value == true then
if (script.Parent.Position2.Position - otherplr.Character.HumanoidRootPart.Position).Magnitude <= 1 then
otherplr.PlayerGui.GeneratorProgress.Frame.Object.Value = nil
otherplr.PlayerGui.GeneratorProgress.Frame.RemoteObject.Value = nil
otherplr.Character.Stats.Fix.Value = false
end
end
end
end
for i,otherplr in pairs(game.Teams.Survivors:GetPlayers()) do
if otherplr.Character ~= nil then
if otherplr.Character.Stats.Fix.Value == true then
if (script.Parent.Position3.Position - otherplr.Character.HumanoidRootPart.Position).Magnitude <= 1 then
otherplr.PlayerGui.GeneratorProgress.Frame.Object.Value = nil
otherplr.PlayerGui.GeneratorProgress.Frame.RemoteObject.Value = nil
otherplr.Character.Stats.Fix.Value = false
end
end
end
end
end
end
first, i tested this when generatormodel placed on workspace it works but when i cloned it from storage to worksapce the script does not work but still print the first line print(“created generator script”) no errors
Can you show me the scripts inside the proximityPrompts? If the proximityPrompts triggering are the problem, then the script(s) detecting their press is probably the issue.
Also, for future reference, you should use variables instead of using script.Parent:WaitForChild() or something like that every time. It will speed up your game. I turned some parts into variables in the following code as an example.
wait(5)
print("created generator script")
local Finished = false
local RS = game:GetService("ReplicatedStorage")
local roundTimer = game.ReplicatedStorage:FindFirstChild("RoundTimer")
local position1 = script.Parent:WaitForChild("Position1")
local position2 = script.Parent:WaitForChild("Position2")
local position3 = script.Parent:WaitForChild("Position3")
local generator = script.Parent:WaitForChild("Generator")
position1.ProximityPrompt.Enabled = true
position2.ProximityPrompt.Enabled = true
position3.ProximityPrompt.Enabled = true
position1.ProximityPrompt.Script.Enabled = true
position2.ProximityPrompt.Script.Enabled = true
position3.ProximityPrompt.Script.Enabled = true
script.Parent.RequestFixing.Event:Connect(function(plr, part)
print("working on checking work")
if plr.Character.Stats.Fix.Value == false and plr.Character.Stats.Downed.Value == false then
if plr.Team == game.Teams.Survivors then
local closedetected = false
for i,otherplr in pairs(game.Teams.Survivors:GetPlayers()) do
if otherplr.Character ~= nil then
if otherplr.Character.Stats.Fix.Value == true then -- stats.fix is custom value for my game
if (part.Position - otherplr.Character.HumanoidRootPart.Position).Magnitude <= 1 then
closedetected = true
print("not able to fix")
break
end
end
end
end
if not closedetected then
print("able to fix")
plr.Character.HumanoidRootPart.CFrame = part.CFrame
plr.Character.Stats.Fix.Value = true
generator.Interact:Play()
plr.PlayerGui.GeneratorProgress.Frame.Object.Value = script.Parent:WaitForChild("Stats").Progress
plr.PlayerGui.GeneratorProgress.Frame.RemoteObject.Value = script.Parent:WaitForChild("SuccessfullEvent")
end
end
end
end)
script.Parent.SuccessfullEvent.OnServerEvent:Connect(function(plrwhofixed)
if plrwhofixed.Character then
if plrwhofixed.Team == game.Teams.Survivors then
if plrwhofixed.Character:FindFirstChild("Stats").Fix.Value == true then
script.Parent:WaitForChild("Stats").Progress.Value = script.Parent:WaitForChild("Stats").Progress.Value + plrwhofixed.Character:FindFirstChild("Stats").GeneratorProgress.Value
end
end
end
end)
while true do -- detect once it finished
wait(0.1)
--print("loop works")
if script.Parent.Stats.Progress.Value >= 100 then
generator.SurfaceLight.Enabled = true
generator.SurfaceLight2.Enabled = true
generator.SurfaceLight3.Enabled = true
generator.SurfaceLight4.Enabled = true
position1.ProximityPrompt.Enabled = false
position2.ProximityPrompt.Enabled = false
position3.ProximityPrompt.Enabled = false
if Finished == false then
Finished = true
if roundTimer.Time.Value > 120 then
roundTimer.Time.Value = roundTimer.Time.Value - 30
elseif roundTimer.Time.Value > 60 then
roundTimer.Time.Value = roundTimer.Time.Value - 20
elseif roundTimer.Time.Value > 0 then
roundTimer.Time.Value = roundTimer.Time.Value - 10
end
end
if script.Parent.Generator.Finished.IsPlaying == false then
script.Parent.Generator.Finished:Play()
end
for i,otherplr in pairs(game.Teams.Survivors:GetPlayers()) do
if otherplr.Character ~= nil then
if otherplr.Character.Stats.Fix.Value == true then
if (script.Parent.Position1.Position - otherplr.Character.HumanoidRootPart.Position).Magnitude <= 1 then
--print("de")
otherplr.PlayerGui.GeneratorProgress.Frame.Object.Value = nil
otherplr.PlayerGui.GeneratorProgress.Frame.RemoteObject.Value = nil
otherplr.Character.Stats.Fix.Value = false
end
end
end
end
for i,otherplr in pairs(game.Teams.Survivors:GetPlayers()) do
if otherplr.Character ~= nil then
if otherplr.Character.Stats.Fix.Value == true then
if (script.Parent.Position2.Position - otherplr.Character.HumanoidRootPart.Position).Magnitude <= 1 then
otherplr.PlayerGui.GeneratorProgress.Frame.Object.Value = nil
otherplr.PlayerGui.GeneratorProgress.Frame.RemoteObject.Value = nil
otherplr.Character.Stats.Fix.Value = false
end
end
end
end
for i,otherplr in pairs(game.Teams.Survivors:GetPlayers()) do
if otherplr.Character ~= nil then
if otherplr.Character.Stats.Fix.Value == true then
if (script.Parent.Position3.Position - otherplr.Character.HumanoidRootPart.Position).Magnitude <= 1 then
otherplr.PlayerGui.GeneratorProgress.Frame.Object.Value = nil
otherplr.PlayerGui.GeneratorProgress.Frame.RemoteObject.Value = nil
otherplr.Character.Stats.Fix.Value = false
end
end
end
end
end
end