Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't my server scripts work in the serverscriptservice???

I've been trying to call a remote event, from a tool, through the replicated storage(where the remote event lives) to a script in serverscriptservice, and while it works fine in solo mode, playing in test, and ingame, it wont work! Why is this? I discovered while playing in test some scripts are appearing in serverscriptservice, and others are not, particularly the one i'm trying to call. However, whilst looking through the server window, in test mode, the scripts are in the Scerverscriptservice. I know the answer is staring me straight in the face. Can anyone help?



-- localscript in tool

local wand = script.Parent

local ArchFolder = wand:WaitForChild("Effects")
local person = wand.Parent
local inc = script.Name
local owner, connect
local Power = wand.Power.Value





function Setup()
for i,p in pairs(game.Players:children()) do
if (p.Character == wand.Parent) then
print("I SEE YOU!")
if (connect ~= nil) then connect:disconnect() end
connect = p.Chatted:connect(PlayerTalked)
owner = p
end
end
end

function PlayerTalked(words)
print("Words!")
if (string.find(words:lower(), inc:lower()) ~= nil) and (wand.Parent == owner.Character) then
print("Running ''" ..inc.. "''")


wand.Activated:Wait()

local Fire = game.ReplicatedStorage.Remotes:WaitForChild(script.Name)
Fire:FireServer(wand)
print("fired event")

print(Fire.Name)
end
end







wand.Equipped:connect(Setup)

the remote function exists in the replicated storage




-- script in serverscriptservice



local Casting = game.ReplicatedStorage.Remotes:WaitForChild(script.Name)


print("seeing if this stupid thing is working")





function CastSpell(Player, wand)
	
	print("Called the remote event")
	print(wand.Parent.Name)
	
	
	

	local Energy = Player.PlayerScripts.Energy
	local Progress = Player.PlayerGui.Bar.Frame.Study.Intelligence.Progress
	local Smarts = Player.PlayerGui.Bar.Frame.Study.Intelligence.Smarts
	
local ArchFolder = wand:WaitForChild("Effects")
local person = wand.Parent
local Power = wand.Power.Value
	
	
	wand.CurrentSpell.Value = script.Name
	
	
	
	
	
if (wand.CurrentSpell.Value == script.Name) and (Energy.Value >= 0) then
		
Energy.Value = Energy.Value - 20/(Power/2)

 

		Progress.Value = Progress.Value + Smarts.Value

	
	
	
	
	
	
	
	
	


script.Disabled = false
local c = wand.Parent.Humanoid:LoadAnimation(wand.SummonSmoke1)
c:play()





local r = ArchFolder.Architype:Clone()
r.Parent = wand.Parent.RightHand
r.Enabled = true

local L = ArchFolder.Architype:Clone()
L.Parent = wand.Parent.LeftHand
L.Enabled = true



local q = Instance.new("Sound")
q.Name = "Sound"
q.Pitch = 0.9
q.SoundId = "http://www.roblox.com/asset/?id=207370820"
q.Volume = 0.3
q.Looped = false
q.archivable = false
q.Parent = game.Workspace
q:play()




local p = Instance.new("Part")
p.formFactor = "Symmetric"
p.Shape = "Ball"
p.Size = Vector3.new(1,1,1)
p.TopSurface = "Smooth"
p.BottomSurface = "Smooth"
p.Transparency = 1 
p.CanCollide = true



ArchFolder.Architype:Clone().Parent = p
p.Architype.Enabled = true
ArchFolder.Sparkles:Clone().Parent = p
p.Sparkles.Enabled = true
ArchFolder.SpellLight:Clone().Parent = p
p.SpellLight.Enabled = true

coroutine.resume(coroutine.create(function()


wait(.3)
r.Enabled = false
L.Enabled = false
script.Disabled = false
wait(6)

r:Remove()
L:Remove()

end))


wait(.3)


local cf = CFrame.new(wand.Parent.UpperTorso.Position, wand.Parent.Humanoid.TargetPoint)
local bv = Instance.new("BodyVelocity")
p.Parent = workspace
p.Name = "MagicSpell"
p.CFrame = cf + cf.lookVector * 4
bv.Parent = p






while wait() do
print("Repeating")


bv.velocity = ((wand.Parent.Humanoid.TargetPoint - p.Position).unit) * 100

 
p.Touched:connect(function(part)

 local nm = p.Architype
p.Architype.Enabled = false
p.Architype.Parent = part
 local sm = p.Sparkles
p.Sparkles.Enabled = false
p.Sparkles.Parent = part
local s = Instance.new("Sound")
s.Name = "Sound"
s.Pitch = 0.9
s.SoundId = "http://www.roblox.com/asset/?id=216866819"
s.Volume = 0.3
s.Looped = false
s.archivable = false
s.Parent = part
s:play()
	p:remove(part,p)
	
	
	
	
	
	wait(10)
	nm:Destroy()
	sm:Destroy()
s:Destroy()
end)
end
end
end







Casting.OnServerEvent:connect(CastSpell)

6 comments

0

you should try debugging. Make a call to the print function for every function, if, etc, to check if it's actually running. It could be that it's Disabled or something.

0

And please post your scripts, how will you be helped without it, we can't read your mind.

0

added the scripts, sorry bout that!

0

there are lots of print functions so i can see what works and what doesnt. Bascially in solo mode it does the whole thing, but in test mode or ingame mode, it stops at the end of the local script.

0

Is this your script?

0

the talky part, to call when the player talks is not mine, but everything else is. only the part to index when the player says the script.name. and that part works ingame.

1 answer

Your script will work fine in ServerScriptService. If something is not working, there is an issue in your code. You can prove that ServerScriptService will work by adding another script and placing a print() inside.

Check for any errors. If there are no errors, something in the script has possibly made a silent error causing the script to stop without error. When I get frustrated with this stuff, I add a print() after everything to find when it stops printing.

1 comment

0

The problem im having, is that i thought it might be part of the script. but the only issue is occuring when its trying to call the event. In play solo, it works fine, but ingame it wont, i check the output in the developer window ingame, and it follows all the prints through the localscript, including after it fires the server, the problem is its not indexing the server script.

This discussion is preserved as it was. New answers, comments, and votes are closed.