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

Bullet Marking Script? How do you make a mark on where a ray ends? [SERIOUS HELP NEEDED]

Asked by
zValerian 108
5 years ago

So I have a script that makes a mark on wherever the player clicks. However it is really glitch 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://3"
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://3"
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)

4
could you refrain from putting "SERIOUS HELP NEEDED" or "URGENT" or anything along those lines User#19524 175 — 5y
1
Everyone needs help and we are not going to prioritise you over others. But unfortunately I cant find a fix to this as I dont really work with rays. iladoga 129 — 5y
0
He means you cannot tell jokes or be sarcastic in any way. It must be "Serious" help. User#21908 42 — 5y
1
Does the script's behavior suggest anything about where exactly it's going wrong? Assuming you wrote it, it should be easy to isolate where the problem is. We can't just look at 80 lines of code without context and reliably help you when all we know is that it doesn't work as intended. vanilla_wizard 336 — 5y
0
it has to do with 66 local hit, pos, normal = game.Workspace:FindPartOnRay(ray) 67 burnHit.CFrame = CFrame.new(pos, pos + normal) zValerian 108 — 5y

Answer this question