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)
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.