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!
Trying to make a flexible script, using bindable events. Whenever a player steps on a part it sends a model name that exists in rep storage, I want it to clone that model into workspace but i keep getting nil
-
What is the issue? Include screenshots / videos if possible!
Whenever i step on a part it sends a name to the main script in severscriptservice and it SHOULD clone that data. but instead I get an error
“ServerScriptService.GameController:40: attempt to call a nil value - Server - GameController:40”
but i know the data is sending because it prints it on the triggers side.
“requested ghostspawn in LobbyPoints - Server - Script:9”
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried swapping the folder to a model in hopes of it working but it didnt work… i didnt see any other posts talking about the same situation
1 Like
Can you insert your code please?
Main Script:
SummonGhost.Event:Connect(function(Zone)
if GameEvents.GhostSpawned.Value == false then
local area = Zone.Name
GameEvents.GhostSpawned.Value = true
local ClonedArea = game.ReplicatedStorage.Areas..area:Clone()
ClonedArea.Parent = workspace
task.wait(120)
ClonedArea:Destroy()
GameEvents.GhostSpawned.Value = false
else
warn("Ghost has already been spawned in")
end
end)
SenderScript:
local SummonGhost = game.ReplicatedStorage.Remotes.SpawnGhost
function onHit(hit)
print(hit.Name.. " hit the lobby trigger!")
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil) and game.ReplicatedStorage.GameEvents.GhostSpawned.Value == false then
local zone = game.ReplicatedStorage.Areas.LobbyPoints
SummonGhost:Fire(zone)
print("requested ghostspawn in ".. zone.Name)
end
end
script.Parent.Touched:connect(onHit)
You forgot to connct to the function that you created.
This should work:
local SummonGhost = game.ReplicatedStorage.Remotes.SpawnGhost
function onHit(hit)
print(hit.Name.. " hit the lobby trigger!")
local human = hit.Parent:findFirstChild("Humanoid")
if (human ~= nil) and game.ReplicatedStorage.GameEvents.GhostSpawned.Value == false then
local zone = game.ReplicatedStorage.Areas.LobbyPoints
SummonGhost:Fire(zone)
print("requested ghostspawn in ".. zone.Name)
end
end
script.Parent.Touched:Connect(function(hit)
onHit(hit)
end)
1 Like
My only assumption as to why it’s not working is this line, I don’t think you need to have to get item from replicatedStorage again since you pass it anyways, so for that line, can’t you do
local ClonedArea = Zone:Clone()
Because the way you have it wont work unless there’s something called Areas..area
in ReplicatedStorage, if you do need to get the zone again with its name, I think you need to do this instead
local ClonedArea = game.ReplicatedStorage.Areas[area]:Clone()
1 Like
Sorry for the late response, thank you for the assistance. I will give this a shot.
1 Like
Thank you so much! this works exactly how I wanted it!
1 Like
Thank you! so much for the assistance!