So I have a script that makes a mark on wherever the player clicks. However it is really glitchy and doesn't really work.
this is how it looks on the floor(where its supposed to be flat) https://gyazo.com/73c47bee3eb199b72c6568e29aa50c67
this is how it looks like on a wall(where it is supposed to be what the floor is like) https://gyazo.com/4928e30f320843d895cdf6ca46598051
Any ideas why this is happening? This is my script:
game.ReplicatedStorage.stupefyy.OnServerEvent:Connect(function(player, name, a) local animation = game.Players:FindFirstChild(name).Character.Humanoid:LoadAnimation(game.Workspace:FindFirstChild(name).Wand.Animation) animation:Play() local characterr = game.Workspace:FindFirstChild(name) lol = Instance.new("Sound") lol.Parent = game.Workspace:FindFirstChild(name).Wand.Tip lol.SoundId = "rbxassetid://2394767558" lol.MaxDistance = 100 lol.EmitterSize = 100 lol:Play() wait(.3) --local ray = Ray.new(game.Workspace:FindFirstChild(name).Wand.Tip.Position(a - game.Workspace:FindFirstChild(name).Wand.Tip.Position).Unit * 750) local character = game.Workspace:FindFirstChild(name) local origin = character.Wand.Tip.Position local ray = Ray.new(origin, (a - origin).Unit * 750) local studsUporDown = 0.25 local timeTillNext = 0.025 local segmentLength = 2 local damageAmount = 10 local part = game.ReplicatedStorage.stup:Clone() part.Parent = workspace studsUporDown = studsUporDown * 100 local function entropy() local x = math.random(-studsUporDown,studsUporDown) / 50 local y = math.random(-studsUporDown,studsUporDown) / 50 local z = math.random(-studsUporDown,studsUporDown) / 50 return Vector3.new(x, y, z) end spawn(function() for i = 0, 750, segmentLength do local Next = ray.Origin + i * ray.Direction.Unit + entropy() local damageRay = Ray.new(part.Position, (Next - part.Position).Unit * segmentLength) part.CFrame = CFrame.new(Next) local hit, End = workspace:FindPartOnRay(damageRay, character, false, true) if hit and hit ~= part then print(hit) local burn = game.ReplicatedStorage.hit part:Destroy() part.CFrame = CFrame.new(End) local hum = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid") if hum then hum:TakeDamage(damageAmount) spawn(function() loll = Instance.new("Sound") loll.Parent = hit loll.SoundId = "rbxassetid://2394767979" loll.MaxDistance = 100 lol.EmitterSize = 100 loll:Play() hum.PlatformStand = true wait(10) hum.PlatformStand = false end) else local burnHit = burn:Clone() --burnHit.CFrame = CFrame.new(End) burnHit.Parent = workspace local hit, pos, normal = game.Workspace:FindPartOnRay(ray) burnHit.CFrame = CFrame.new(pos, pos * normal) loll = Instance.new("Sound") loll.Parent = burnHit loll.SoundId = "rbxassetid://2394767979" loll.MaxDistance = 100 lol.EmitterSize = 100 loll:Play() end break end wait(timeTillNext) end end) end)
it has to do with
local hit, pos, normal = game.Workspace:FindPartOnRay(ray) burnHit.CFrame = CFrame.new(pos, pos + normal)