Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Event can't be seen from server script?

Asked by 4 years ago

Hello! I created a script to make a weld on click and for some reason it doesn't see when the event fired. The first script sees the event perfectly, with:

local event = game.ReplicatedStorage.ClassData.Bloxxer.BWeld
if event then
    print("okkkk")
end

But the other script, which runs the same line, doesn't print "okkkk?"

Here's the code:

--Server Script

--In StarterPack


game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) local character = char local event = game.ReplicatedStorage.ClassData.Bloxxer.BWeld if event then print("okkkk?") end event.OnServerEvent:Connect(function() print("okok") local part = char.BSword local weld = Instance.new("Weld",part) part.Parent = plr.Character weld.Part0 = part --Attach to the handle weld.Part1 = character["RightHand"] --Attach to the right hand. weld.C0 = CFrame.new(-8, -1, -7) + Vector3.new(0,character["RightHand"].Size.Y/1,0) weld.C0 = CFrame.Angles(0,math.rad(180), 140) end) end) end)

And the code that Fires it:

--Local Script

--In StarterPack


wait(2) local plr = game.Players.LocalPlayer local class = plr.Character.Class local event = game.ReplicatedStorage.ClassData.Bloxxer.BWeld local b = script.Parent if event then print("okkkk") end local function makeclass() local part = game.ReplicatedStorage.ClassData.Bloxxer.BloxxerSword:Clone() part.Name = "BSword" event:FireServer(plr) print("les go") b.Attack.Disabled = false end local function endclass() b.Attack.Disabled = true end class.Changed:Connect(function(class) if class == 1 then makeclass() if class ~= 1 then endclass() end end end) if class.Value == 1 then makeclass() end

Any help's appreciated!

0
Try adding a wait above in the server script too. Ziffixture 6913 — 4y

Answer this question